<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:13 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-415] collection.remove() may return null when it should return WriteResult or throw an exception</title>
                <link>https://jira.mongodb.org/browse/JAVA-415</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I&apos;m experiencing &amp;lt;&amp;lt;null&amp;gt;&amp;gt; results when calling&lt;/p&gt;

&lt;p&gt;collection.remove(...)&lt;/p&gt;

&lt;p&gt;where the contract says that either a WriteResult is returned or an exception is thrown. &lt;/p&gt;

&lt;p&gt;I&apos;ve tracked this down to DBTCPConnector#_checkWriteError that ends with&lt;/p&gt;

&lt;p&gt; WriteResult _checkWriteError( DB db , MyPort mp , DBPort port , WriteConcern concern )&lt;br/&gt;
        CommandResult e = null;&lt;br/&gt;
        e = port.runCommand( db , concern.getCommand() );&lt;br/&gt;
        if ( ! e.hasErr() )&lt;br/&gt;
            return new WriteResult( e , concern );&lt;br/&gt;
       e.throwOnError();&lt;br/&gt;
       return null;&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;if&lt;/p&gt;

&lt;p&gt;       e.throwOnError();&lt;/p&gt;

&lt;p&gt;does not throw an exception ( ok() || !hasErr())&lt;/p&gt;

&lt;p&gt;       return null;&lt;/p&gt;

&lt;p&gt;is returned.&lt;/p&gt;</description>
                <environment>Windows 7, MongoDB 1.8.2, Java Driver 2.6.5</environment>
        <key id="20994">JAVA-415</key>
            <summary>collection.remove() may return null when it should return WriteResult or throw an exception</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="cpesch">Christian pesch</reporter>
                        <labels>
                    </labels>
                <created>Mon, 15 Aug 2011 16:13:40 +0000</created>
                <updated>Sun, 12 Aug 2012 03:53:32 +0000</updated>
                            <resolved>Sun, 12 Aug 2012 03:53:32 +0000</resolved>
                                    <version>2.6.5</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="152587" author="jeff.yemin" created="Sun, 12 Aug 2012 03:53:32 +0000"  >&lt;p&gt;This was fixed in commit 3d5458e5fbbedd2381f3c675fc140eae94ea2949&lt;/p&gt;</comment>
                            <comment id="119956" author="cpesch" created="Wed, 16 May 2012 07:52:01 +0000"  >&lt;p&gt;No, I&apos;ve refactored my code to not rely on the result anymore. IIRC the bug is in the checks of e.throwOnError(): If has to throw an exception and not check for conditions.&lt;/p&gt;</comment>
                            <comment id="119568" author="jeff.yemin" created="Tue, 15 May 2012 12:32:20 +0000"  >&lt;p&gt;Christian, apologies for taking so long to respond to this.  &lt;/p&gt;

&lt;p&gt;I&apos;m looking at the code and I don&apos;t see how this could happen.  If e.hasErr() is true, then e.throwOnError() will throw an exception.  The return of null at the end of _checkWriteError is just there to avoid a compilation error.  Do you still have a test case than demonstrates the bug?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhbsf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14710</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>