[JAVA-502] cannot remove nulls from array Created: 05/Jan/12 Updated: 05/Jan/12 Resolved: 05/Jan/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API, Documentation |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Josh Rogers | Assignee: | Scott Hernandez (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver, update | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java Version: 1.6.0_23 Sun Microsystems Inc. – OpenJDK Server VM |
||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
I use the following update: collection.update(q, new BasicDBObject("$pull", new BasicDBObject("x",null)) and I receive the following error: 2012.01.05 10:34:36 root - Error: java.lang.NullPointerException: can't save a null object The null is created in the first place as a result of using the $unset: collection.update(q, new BasicDBObject("$unset", new BasicDBObject("x"+".$",1))) I cannot use the $pull in replacement of $unset because i would require exact matching, which doesn't seem possible as documented: I had assumed that using the null pointer reference was ok based on the post by Andrew Wharton specified in: http://www.mongodb.org/display/DOCS/Java+Types Is this the correct way to be doing this? The only other way to accomplish this would be to query the entire array, modify it, then insert it back; but I would rather not do this as this could lead to a race condition. |
| Comments |
| Comment by Josh Rogers [ 05/Jan/12 ] |
|
Sorry. I had assumed that it was a result of passing in a null pointer that I was getting a NullPointerException. It was actually because my query doc was null. I'm not really sure how to close this issue. |