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

MongoCollection.aggregate() throws NullPointerException when no batchSize is specified

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.1, 3.2.0
    • Affects Version/s: 3.0.4
    • Component/s: Query Operations
    • None
    • Environment:
      Java 7
      MongoDB server version 3.0.x

      When executing an aggregate pipeline, the Java driver gives me a NullPointerException without further explanation.

      While debugging I found that it's happening while trying to unbox AggregateIterableImpl.batchSize of type java.lang.Integer to be written to field FindIterableImpl.findOptions.batchSize of type int.

      When I specify a batchSize() at the Aggregate other than null, e.g. explicitly setting it to "0" (the documented default value), everything is fine.

      So, instead of just using

      List<Document> result = collection.aggregate(pipeline).into(new LinkedList<Document>);

      I need to write

      List<Document> result = collection.aggregate(pipeline).batchSize(0).into(new LinkedList<Document>);

      which is rather unusual and smells a bit bad .

      I think it would help to change the type of the batchSize attribute of AggregateIterableImpl from java.lang.Integer to int, but I cannot tell whether it has any side-effects...

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            rene.zanner@lpsolutions.com Rene Zanner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: