<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:55:33 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-1808] Mongo java driver insertOne() NullPointerException </title>
                <link>https://jira.mongodb.org/browse/JAVA-1808</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;when use mongo java driver(3.0.0rc1) to insert doc into mongodb (3.0.0 ) which was installed on a virtual server built by VMware vSphere,the API insertOne() could not work. The call stack shown as below:&lt;br/&gt;
Caused by: java.lang.NullPointerException &lt;br/&gt;
at com.mongodb.connection.ProtocolHelper.isCommandOk(ProtocolHelper.java:61) &lt;br/&gt;
at com.mongodb.connection.WriteCommandProtocol.receiveMessage(WriteCommandProtocol.java:189) &lt;br/&gt;
at com.mongodb.connection.WriteCommandProtocol.execute(.java:76) &lt;br/&gt;
at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:66) &lt;br/&gt;
at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37) &lt;br/&gt;
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) &lt;br/&gt;
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) &lt;br/&gt;
at com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:108) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation$Run$2.executeWriteCommandProtocol(MixedBulkWriteOperation.java:416) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation$Run$RunExecutor.execute(MixedBulkWriteOperation.java:604) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation$Run.execute(MixedBulkWriteOperation.java:363) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:148) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:141) &lt;br/&gt;
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:186) &lt;br/&gt;
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:141) &lt;br/&gt;
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:72) &lt;br/&gt;
at com.mongodb.Mongo.execute(Mongo.java:745) &lt;br/&gt;
at com.mongodb.Mongo$2.execute(Mongo.java:728) &lt;br/&gt;
at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:482) &lt;br/&gt;
at com.mongodb.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:277) &lt;/p&gt;

&lt;p&gt;PS: this exception happens not all the time.and never happens on windows&lt;/p&gt;</description>
                <environment>CentOS 6.5 64bits (Installed on vSphere virtual machine)</environment>
        <key id="203216">JAVA-1808</key>
            <summary>Mongo java driver insertOne() NullPointerException </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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="windofthesky">windofthesky</reporter>
                        <labels>
                    </labels>
                <created>Mon, 11 May 2015 04:42:00 +0000</created>
                <updated>Thu, 28 May 2015 18:36:58 +0000</updated>
                            <resolved>Mon, 18 May 2015 17:38:14 +0000</resolved>
                                    <version>3.0.0</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="916958" author="jeff.yemin" created="Mon, 18 May 2015 17:38:14 +0000"  >&lt;p&gt;Duplicates &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1811&quot; title=&quot;NullPointerException if command response is missing an ok field or errmsg field&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1811&quot;&gt;&lt;del&gt;JAVA-1811&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="912743" author="jeff.yemin" created="Wed, 13 May 2015 13:36:46 +0000"  >&lt;p&gt;I don&apos;t think the socketTimeout default is the problem.  It&apos;s just uncovering this bug, which is that sometimes the server will return a command response without an ok field, and the driver is not properly handling it.  When this is fixed what&apos;s going to happen is that the driver will throw a MongoCommandException instead of a NullPointerException, as a command that responds without an ok field with some sort of truth value (true, or 1), was not a successfully executed command.&lt;/p&gt;</comment>
                            <comment id="912336" author="windofthesky" created="Wed, 13 May 2015 00:54:43 +0000"  >&lt;p&gt;Hi,Jeff.&lt;br/&gt;
I think the problem comes from these code as below:&lt;br/&gt;
static boolean isCommandOk(final BsonDocument response) {&lt;br/&gt;
        if (!response.containsKey(&quot;ok&quot;)) &lt;/p&gt;
{ 
            return false;
        }
&lt;p&gt;        BsonValue okValue = response.get(&quot;ok&quot;);&lt;br/&gt;
        if (okValue.isBoolean()) &lt;/p&gt;
{
            return okValue.asBoolean().getValue();
        }
&lt;p&gt; else if (okValue.isNumber()) &lt;/p&gt;
{
            return okValue.asNumber().intValue() == 1;
        }
&lt;p&gt; else &lt;/p&gt;
{
            return false;
        }
&lt;p&gt;    }&lt;/p&gt;

&lt;p&gt;and here is the things that may help:&lt;br/&gt;
&amp;gt; The document that the application is inserting&lt;br/&gt;
        Document msgdoc = new Document();	&lt;br/&gt;
        msgdoc.append(&quot;msg_id&quot;, MSG_ID);&lt;br/&gt;
	msgdoc.append(&quot;msg_content&quot;, msg);&lt;/p&gt;

&lt;p&gt;&amp;gt; The list of indexes on the collection that the document is being inserted into.&lt;br/&gt;
        I use the default _id index(cause this is a demo project).&lt;/p&gt;

&lt;p&gt;&amp;gt;The topology of the server (standalone, replica set, sharded)&lt;br/&gt;
        the mongo server is a standalone one.&lt;/p&gt;

&lt;p&gt;&amp;gt;The server logs for the server that the insert was executed on.&lt;br/&gt;
   here is the insert command log as below:&lt;br/&gt;
   &quot;2015-04-21T17:49:24.574+0800 I COMMAND  &lt;span class=&quot;error&quot;&gt;&amp;#91;conn68&amp;#93;&lt;/span&gt; command t_MESSAGE_2015-4-21.$cmd command: insert { insert: &quot;col_msg&quot;, ordered: true, documents: [ &lt;/p&gt;
{ _id: ObjectId(&apos;55361d24b5d6e51b8001d728&apos;), msg_id: &quot;1920437&quot;, msg_content: &quot;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&#255;&quot; }
&lt;p&gt; ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:40 locks:{} 136ms&quot;&lt;/p&gt;

&lt;p&gt;PS: according to the mongo java driver source code,in MongoClientOptions.java,the default &quot;socketTimeout&quot; is 0ms,which means no timeout. when I try to set the &quot;socketTimeout&quot; to 300ms,this NullPointerException will not happen anymore.So I think maybe we should modify the default &quot;socketTimeout&quot; to a proper value avoid the bad network condition.&lt;/p&gt;
</comment>
                            <comment id="909798" author="jeff.yemin" created="Mon, 11 May 2015 12:06:45 +0000"  >&lt;p&gt;The server should never return a command response without an ok field, and it appears that&apos;s what&apos;s happening.  Can you provide any more information that could help us to reproduce this issue?  Some things that may help:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The document that the application is inserting&lt;/li&gt;
	&lt;li&gt;The list of indexes on the collection that the document is being inserted into.&lt;/li&gt;
	&lt;li&gt;The topology of the server (standalone, replica set, sharded)&lt;/li&gt;
	&lt;li&gt;The server logs for the server that the insert was executed on.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="203662">JAVA-1811</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10012"><![CDATA[Major Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <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|hrersv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="552">Java Sprint 20</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>