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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: 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 Lawley
              Reporter:
              Jens Suhr
              None
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: