[JAVA-2404] Cannot use BasicDBList as value with Updates builder methods Created: 09/Dec/16 Updated: 09/Jan/17 Resolved: 09/Jan/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | 3.5.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Giordano Maestro | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
If you use the Updates class in this way Updates.set("array", value) where value is a BasicDbList Object the result of the insert is { } The list BasicDBList is now a document instead of a list |
| Comments |
| Comment by Githook User [ 09/Jan/17 ] | |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: Othewise, it will provide the DBObjectCodec for BasicDBList which is incorrect. With this change, | |
| Comment by Ross Lawley [ 09/Dec/16 ] | |
|
Hi Giordano Maestro, Thanks for the ticket, this is an interesting corner case and essentially is a configuration issue with the codec registry. The BasicDbList is a subclass of DBObject due to the class reflecting the way BSON lists work. When the Updates.set helper looks up the class for the value in the CodecRegistry its returned a DBObjectCodec as its seeing a DBObject class and treating it as such. There are a couple of work arounds, one would be to add a specific codec to handle BasicDBLists, or a simpler way would be to explicitly convert the BasicDbList to a List eg:
Ross |