Java Driver
  1. Java Driver
  2. JAVA-863

gridFs.remove((DBObject)null) removes all elements from bucket

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major - P3 Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.11.2
    • Fix Version/s: 2.12.0, 3.0.0
    • Component/s: GridFS
    • Labels:
      None
    • Environment:
      java version "1.7.0_25"
      Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
      Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
      Mongodb version: 2.0.6
      Java driver version: 2.11.2
    • Operating System:
      Windows
    • # Replies:
      8
    • Last comment by Customer:
      false
    • Sprint:
      Sprint 1

      Description

      When passing null to GridFS.remove(DBObject dbobject) all files of the current bucket are removed. This is inconsistent compared to the other remove() methods of GridFS:

      gridFs.remove((String)null); // nothing happens
      gridFs.remove((ObjectId)null); // nothing happens
      gridFs.remove((DBObject)null); // all files from bucket are removed

      If this is intended behavior it should be documented in the javadoc comment.

      1. Main.java
        0.9 kB
        Micha S.

        Activity

        Hide
        Jeff Yemin
        added a comment -

        Hi Micha,

        We're going to look into doing something about this in the next release.

        Show
        Jeff Yemin
        added a comment - Hi Micha, We're going to look into doing something about this in the next release.
        Hide
        Jeff Yemin
        added a comment -

        My preference is to change (and Javadoc, of course) all three methods to throw IllegalArgumentException if the parameter is null. This would more closely match the behavior of DBCollection.remove, which also throws if the query is null (though it throws an NPE, which we should also change).

        Show
        Jeff Yemin
        added a comment - My preference is to change (and Javadoc, of course) all three methods to throw IllegalArgumentException if the parameter is null. This would more closely match the behavior of DBCollection.remove, which also throws if the query is null (though it throws an NPE, which we should also change).
        Hide
        Neeraj Bhatt
        added a comment -

        Hi Jeff
        I have raised a pull request to fix this bug

        Show
        Neeraj Bhatt
        added a comment - Hi Jeff I have raised a pull request to fix this bug
        Hide
        Githook User
        added a comment -

        Author:

        {u'username': u'neerajbhatt', u'name': u'neerajbhatt', u'email': u'neerajbhatt2000@gmail.com'}

        Message: https://jira.mongodb.org/browse/JAVA-863, fixed null checks in reove method
        Branch: master
        https://github.com/mongodb/mongo-java-driver/commit/6fad5e473d6f37a640d36926ff66c8460d386cf2

        Show
        Githook User
        added a comment - Author: {u'username': u'neerajbhatt', u'name': u'neerajbhatt', u'email': u'neerajbhatt2000@gmail.com'} Message: https://jira.mongodb.org/browse/JAVA-863 , fixed null checks in reove method Branch: master https://github.com/mongodb/mongo-java-driver/commit/6fad5e473d6f37a640d36926ff66c8460d386cf2
        Hide
        Githook User
        added a comment -

        Author:

        {u'username': u'neerajbhatt', u'name': u'neerajbhatt', u'email': u'neerajbhatt2000@gmail.com'}

        Message: https://jira.mongodb.org/browse/JAVA-863, fixed null checks in remove method
        Branch: master
        https://github.com/mongodb/mongo-java-driver/commit/4ef307e7ad9174e2ee138b01dcb2424017b9822d

        Show
        Githook User
        added a comment - Author: {u'username': u'neerajbhatt', u'name': u'neerajbhatt', u'email': u'neerajbhatt2000@gmail.com'} Message: https://jira.mongodb.org/browse/JAVA-863 , fixed null checks in remove method Branch: master https://github.com/mongodb/mongo-java-driver/commit/4ef307e7ad9174e2ee138b01dcb2424017b9822d
        Hide
        Githook User
        added a comment -

        Author:

        {u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

        Message: JAVA-863: Added null checks in remove methods for GridFS.
        Branch: 3.0.x
        https://github.com/mongodb/mongo-java-driver/commit/06d7d907d64d130bc84242c8c4fcbc3ca20afafe

        Show
        Githook User
        added a comment - Author: {u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'} Message: JAVA-863 : Added null checks in remove methods for GridFS. Branch: 3.0.x https://github.com/mongodb/mongo-java-driver/commit/06d7d907d64d130bc84242c8c4fcbc3ca20afafe
        Hide
        Jeff Yemin
        added a comment -

        All three remove methods in GridFS now throw IllegalArgumentException if the parameter value is null.

        Show
        Jeff Yemin
        added a comment - All three remove methods in GridFS now throw IllegalArgumentException if the parameter value is null.
        Hide
        Jeff Yemin
        added a comment -

        Hi Micha,

        Would you mind testing with 2.12.0-rc0, available either on github or Maven Central?

        Thanks,
        Jeff

        Show
        Jeff Yemin
        added a comment - Hi Micha, Would you mind testing with 2.12.0-rc0, available either on github or Maven Central ? Thanks, Jeff

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              6 weeks, 6 days ago
              Date of 1st Reply:

              Agile