[JAVA-1106] Empty objects and arrays not handled correctly in results. Created: 05/Feb/14 Updated: 16/Mar/15 Resolved: 16/Mar/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.11.4 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Graham Thomson | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Any |
||
| Backwards Compatibility: | Major Change |
| Description |
|
Values in an object returned from a query may be an empty object or an empty array. If such cases, calling bo.keySet().isEmpty() always returns false (the result is hardwired in the method override), depsite the fact that bo.keySet().size() == 0. A simple fix is to change the org.bson.util.StringRangeSet.isEmpty() implementation to: @Override |
| Comments |
| Comment by Jeffrey Yemin [ 16/Mar/15 ] | ||||||||||||||
|
Tested in master, which has a simplified implementation of StringRangeSet, and isEmpty works properly. | ||||||||||||||
| Comment by Graham Thomson [ 06/May/14 ] | ||||||||||||||
|
I can refine it a little - as pointed out, the problem pertains to org.bson.util.StringRangeSet. After digging deeper into the code I realise that this is only used by org.bson.types.BasicBSONList. So my apologies - it is actually only arrays that are not handled correctly in results. The following snippet reproduces the problem:
And produces the following output:
| ||||||||||||||
| Comment by Michael Reynolds [ 04/May/14 ] | ||||||||||||||
|
Can you provide steps to reproduce this issue? | ||||||||||||||
| Comment by Jeffrey Yemin [ 06/Feb/14 ] | ||||||||||||||
|
Never mind, I thought you meant that this happens with empty documents also. | ||||||||||||||
| Comment by Jeffrey Yemin [ 05/Feb/14 ] | ||||||||||||||
|
Would you mind adding a small test program that demonstrates the problem? Thanks, |