[JAVA-267] update DBCusor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate Created: 07/Feb/11 Updated: 17/Mar/11 Resolved: 07/Feb/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.4 |
| Fix Version/s: | 2.5 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Andy Jefferson | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
If I do the following DBCursor curs = db.getCollection("Person").find(query); where query is "{ "firstName" : { "$eq" : "Daffy"}} then I get Yes, I (now) know the query object represents invalid BSON (but then someone who is learning this API wouldn't know that, since "$eq" seems logical when you have "$ne", "$gt" etc). The fact remains though that there is nothing in the API for Cursor.hasNext() (or java.util.Iterator.hasNext() too which is cleaimed to be implemented here) that permits such an exception. Invalid BSON should be detected in "DBCollection.find()" IMHO, so the user doesn't get unexpected exceptions thrown |
| Comments |
| Comment by Antoine Girbal [ 07/Feb/11 ] |
|
changed:
|
| Comment by auto [ 07/Feb/11 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by Scott Hernandez (Inactive) [ 07/Feb/11 ] |
|
If you use the Iterable/Iterator interface there is no place to document this. Users wouldn't even know where to look in the javadocs, most likley. It is the same issue with checked exceptions since your can't alter the interface. |
| Comment by Eliot Horowitz (Inactive) [ 07/Feb/11 ] |
|
We should update javadoc |
| Comment by Andy Jefferson [ 07/Feb/11 ] |
|
So is the javadoc going to be updated ? since "works as designed" implies that they declare exactly what can happen, and those on this page |
| Comment by Eliot Horowitz (Inactive) [ 07/Feb/11 ] |
|
find() doesn't actually go to the database. It would be impossible to have find() throw all possible errors. |
| Comment by Andy Jefferson [ 07/Feb/11 ] |
|
For the record, the log does detect this error, as } just that the Java API needs to detect it in a different place, via find(). |