[JAVA-1760] Query failure with nested BasicDBObject created from Map Created: 13/Apr/15 Updated: 11/May/15 Resolved: 20/Apr/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | 3.0.1, 3.1.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Jochen Kemnade | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | regression | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
The attached groovy script works with 2.13.0 but fails with 3.0.0. |
| Comments |
| Comment by Jeffrey Yemin [ 05/May/15 ] |
|
Closed for 3.0.1 release. |
| Comment by Githook User [ 20/Apr/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: When encoding a DBObject, if a value implements both Iterable and Map, encode it as a document rather than array. This preserves compatibility with 2.x encoding behavior. |
| Comment by Githook User [ 20/Apr/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: When encoding a DBObject, if a value implements both Iterable and Map, encode it as a document rather than array. This preserves compatibility with 2.x encoding behavior. |
| Comment by Jeffrey Yemin [ 13/Apr/15 ] |
|
That's an option, but in this case I think we should prefer backwards compatibility to a breaking change. |
| Comment by Jochen Kemnade [ 13/Apr/15 ] |
|
Yes, that would probably solve my issue and make 3.x behave like 2.x did, but I still think that an exception should be thrown rather than guessing which interface is more significant. |
| Comment by Jeffrey Yemin [ 13/Apr/15 ] |
|
You want to try switching the the check for Map and Iterable and see if that resolves it for you? Or I can get you a patch if that would be easier. |
| Comment by Jochen Kemnade [ 13/Apr/15 ] |
|
It could be com.mongodb.DBObjectCodec.writeValue(BsonWriter, EncoderContext, Object). If the object implements Iterable (which PersistentArrayMap does), it is silently treated as an array, regardless of whether it also implements Map. I think that ambiguities like that should lead to an error. |