[JAVA-1808] Mongo java driver insertOne() NullPointerException Created: 11/May/15 Updated: 28/May/15 Resolved: 18/May/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | windofthesky | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
CentOS 6.5 64bits (Installed on vSphere virtual machine) |
||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Major Change | ||||||||
| Description |
|
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: PS: this exception happens not all the time.and never happens on windows |
| Comments |
| Comment by Jeffrey Yemin [ 18/May/15 ] |
|
Duplicates |
| Comment by Jeffrey Yemin [ 13/May/15 ] |
|
I don't think the socketTimeout default is the problem. It'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'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. |
| Comment by windofthesky [ 13/May/15 ] |
|
Hi,Jeff. BsonValue okValue = response.get("ok"); else if (okValue.isNumber()) { return okValue.asNumber().intValue() == 1; }else { return false; }} and here is the things that may help: > The list of indexes on the collection that the document is being inserted into. >The topology of the server (standalone, replica set, sharded) >The server logs for the server that the insert was executed on. ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:40 locks:{} 136ms" PS: according to the mongo java driver source code,in MongoClientOptions.java,the default "socketTimeout" is 0ms,which means no timeout. when I try to set the "socketTimeout" to 300ms,this NullPointerException will not happen anymore.So I think maybe we should modify the default "socketTimeout" to a proper value avoid the bad network condition. |
| Comment by Jeffrey Yemin [ 11/May/15 ] |
|
The server should never return a command response without an ok field, and it appears that's what's happening. Can you provide any more information that could help us to reproduce this issue? Some things that may help:
|