[JAVA-3279] distinct on using non-sparse index throws NPE Created: 24/Apr/19 Updated: 28/Oct/23 Resolved: 06/Aug/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Async, Query Operations |
| Affects Version/s: | None |
| Fix Version/s: | 3.11.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Simon Schenk | Assignee: | John Stewart (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongo-scala-driver 2.6.0 |
||
| Issue Links: |
|
||||||||
| Description |
|
Calling `.distinct` on a collection with a non-sparse index on a field, that is missing from at least one document, results in a NullPointerException. The reason is that due to the index not being sparse, null is added to the distinct values for the missing field. `AbstractSubscription` checks if the entire returned array is null (which it isn't), but not the individual elements. `resultsQueue.addAll(results)` then fails with an NPE. Steps to reproduce: ```scala yield dist should contain theSameElementsAs Seq(null) ``` ] to server localhost:12345 ] to server localhost:12345 |
| Comments |
| Comment by Githook User [ 06/Aug/19 ] |
|
Author: {'name': 'John Stewart', 'email': 'john.stewart@mongodb.com', 'username': 'jstewart-mongo'}Message: Handle null results for reactive applications
|
| Comment by Ian Whalen (Inactive) [ 29/Apr/19 ] |
|
Hey sschenk moving this from SCALA to JAVA because the bug is actually inside of the Java driver code. |