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

DBCursor getters should not return copies for mutable objects

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

      The 3.0.x branch implementation of DBCursor.getQuery and DBCursor.getKeysWanted return a copy of the internal property, whereas before they returned a reference to the internal copy. This break clients who do:

      DBCursor cursor = collection.find(new BasicDBObject());
      cursor.getQuery().put("x", 1);
      

      since because getQuery returns a copy, the put has no effect on the query that's actually performed.

      This should be reverted to the previous behavior.

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

              Created:
              Updated:
              Resolved: