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

Kotlin extensions: `and` and `or` throw a NullPointerException if one of the elements in the argument's list is null

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Kotlin
    • None
    • None
    • Java Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      With signatures of 

      fun and(filters: Iterable<Bson?>): Bson 

      and

      and(vararg filters: Bson?): Bson

      , I'd expect the function to correctly handle null values. But as they are passed directly to the Java implementation which only checks that the list itself is not null, an NPE is thrown when the filter is converted to a BsonDocument and filters contains any null value:

      for (Bson filter : filters) {
          clauses.add(filter.toBsonDocument(documentClass, codecRegistry));
      }
      

       
      Possible solutions:

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            jens.suhr@dreamit.de Jens Suhr
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              None
              None
              None
              None