Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2429

DBCollection.distinct() fails when a null value is in the result

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.2
    • Affects Version/s: 3.4.0
    • Component/s: Query Operations
    • None

      When I execute the command db.getCollection("collname").distinct("fieldname"); on a collection that contains a document like

      {
        "_id": "...",
        "fieldname": null 
      }
      
      Exception in thread "main" java.lang.IllegalArgumentException: The value for key value can not be null
      	at org.bson.BsonDocument.put(BsonDocument.java:721)
      	at org.bson.BsonDocument.<init>(BsonDocument.java:83)
      	at com.mongodb.DBCollection$1.apply(DBCollection.java:1185)
      	at com.mongodb.DBCollection$1.apply(DBCollection.java:1182)
      	at com.mongodb.MappingIterable$1.apply(MappingIterable.java:53)
      	at com.mongodb.OperationIterable.forEach(OperationIterable.java:73)
      	at com.mongodb.MappingIterable.forEach(MappingIterable.java:50)
      	at com.mongodb.MappingIterable.into(MappingIterable.java:60)
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1189)
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1161)
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1136)
      	at com.mongodb.DBCollection.distinct(DBCollection.java:1124)
      	at DbBugTest.main(DbBugTest.java:13)
      

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            mango Jan S.
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: