[JAVA-1254] Some helper methods wrapping commands do not call throwOnError on the result Created: 21/May/14  Updated: 01/Apr/16  Resolved: 26/Jun/14

Status: Closed
Project: Java Driver
Component/s: Command Operations
Affects Version/s: 2.12.0
Fix Version/s: 2.12.3

Type: Bug Priority: Major - P3
Reporter: John Morales Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

From what I gather, the general contract of the Collection and DB API methods is:

  • DB.command() will return a CommandResult to the user who then take responsibility to check ok() or throwOnError() as they wish.
  • The "helper" methods that wrap commands, e.g., distinct() call throwOnError for the user automatically.

However from what I see there are several "helpers" that do not, making the pattern sort of inconsistent for users. The examples that I was able to find where throwOnError() is not called:

  • DB.getStats()
  • Mongo.fsync()
  • Mongo.fsyncAndLock()
  • DBCollection.aggregate() returning an AggregationOutput


 Comments   
Comment by Githook User [ 01/Aug/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Ensure helpers call throwOnError();

JAVA-1254
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/06e1d91f7bdec4b00c905d63d7083c6470d1e6c1

Comment by Githook User [ 26/Jun/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Ensure helpers call throwOnError();

JAVA-1254
Branch: 2.12.x
https://github.com/mongodb/mongo-java-driver/commit/06e1d91f7bdec4b00c905d63d7083c6470d1e6c1

Comment by Ross Lawley [ 25/Jun/14 ]

https://github.com/mongodb/mongo-java-driver/pull/221
https://github.com/mongodb/mongo-java-driver/pull/222

Generated at Thu Feb 08 08:54:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.