[JAVA-2419] org.bson.codecs.IterableCodec throws NPE when decoding ARRAYs Created: 23/Dec/16 Updated: 11/Jan/17 Resolved: 09/Jan/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.4.0 |
| Fix Version/s: | 3.5.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Michael Weber | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Assuming you have a structure like the following within mongo db and try to decode it manually, not using org.bson.codecs.DocumentCodec a NullPointerException is being thrown if you trty to decode a nested ARRAY structure. database-object: { "_id" : ObjectId("585d002202ef6c0c985cd350"), "listOfList" : [ [ ] ] }Stacktrace:
SampleCode to replay:
Remark: I am not 100% sure tht IterableCodec should be able to handle Arrays, I just saw the comments in org.bson.codecs.BsonTypeClassMap stating that ARRAYS are supported. Unfortunately there is no mapping in th defaults section. |
| Comments |
| Comment by Githook User [ 11/Jan/17 ] | ||||||
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: | ||||||
| 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: Lazily throw exceptions for missing codecs in BsonTypeCodecMap. This allows use of BsonTypeCodecMap | ||||||
| Comment by Jeffrey Yemin [ 23/Dec/16 ] | ||||||
|
It should be able to handle arrays. You can work around it like this:
|