<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:53 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-267] update DBCusor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate</title>
                <link>https://jira.mongodb.org/browse/JAVA-267</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;If I do the following&lt;/p&gt;

&lt;p&gt;DBCursor curs = db.getCollection(&quot;Person&quot;).find(query);&lt;br/&gt;
while (curs.hasNext())&lt;br/&gt;
{&lt;br/&gt;
   ...&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;where query is &quot;{ &quot;firstName&quot; : { &quot;$eq&quot; : &quot;Daffy&quot;}} &lt;/p&gt;

&lt;p&gt;then I get&lt;br/&gt;
com.mongodb.MongoInternalException: couldn&apos;t get next element&lt;br/&gt;
        at com.mongodb.DBCursor.hasNext(DBCursor.java:459) &lt;/p&gt;

&lt;p&gt;Yes, I (now) know the query object represents invalid BSON (but then someone who is learning this API wouldn&apos;t know that, since &quot;$eq&quot; seems logical when you have &quot;$ne&quot;, &quot;$gt&quot; etc). &lt;/p&gt;

&lt;p&gt;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 &quot;DBCollection.find()&quot; IMHO, so the user doesn&apos;t get unexpected exceptions thrown&lt;/p&gt;</description>
                <environment></environment>
        <key id="14547">JAVA-267</key>
            <summary>update DBCusor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="antoine">Antoine Girbal</assignee>
                                    <reporter username="datanucleus">Andy Jefferson</reporter>
                        <labels>
                    </labels>
                <created>Mon, 7 Feb 2011 10:35:35 +0000</created>
                <updated>Thu, 17 Mar 2011 19:13:55 +0000</updated>
                            <resolved>Mon, 7 Feb 2011 22:00:18 +0000</resolved>
                                    <version>2.4</version>
                                    <fixVersion>2.5</fixVersion>
                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="23301" author="antoine" created="Mon, 7 Feb 2011 22:00:18 +0000"  >&lt;p&gt;changed:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;these methods may now throw MongoException (removed MongoInternalException wrapper) which is the actual error that happened&lt;/li&gt;
	&lt;li&gt;change doc to state that exceptions may be thrown&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="23299" author="auto" created="Mon, 7 Feb 2011 21:58:24 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-267&quot; title=&quot;update DBCusor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-267&quot;&gt;&lt;del&gt;JAVA-267&lt;/del&gt;&lt;/a&gt;: update DBCursor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/91dcab11ce7c152bc32523c3496fb838479235f2&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/91dcab11ce7c152bc32523c3496fb838479235f2&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="23239" author="scotthernandez" created="Mon, 7 Feb 2011 15:07:16 +0000"  >&lt;p&gt;If you use the Iterable/Iterator interface there is no place to document this. Users wouldn&apos;t even know where to look in the javadocs, most likley.&lt;/p&gt;

&lt;p&gt;It is the same issue with checked exceptions since your can&apos;t alter the interface. &lt;/p&gt;</comment>
                            <comment id="23236" author="eliot" created="Mon, 7 Feb 2011 13:31:01 +0000"  >&lt;p&gt;We should update javadoc&lt;/p&gt;</comment>
                            <comment id="23235" author="datanucleus" created="Mon, 7 Feb 2011 13:27:08 +0000"  >&lt;p&gt;So is the javadoc going to be updated ? since &quot;works as designed&quot; implies that they declare exactly what can happen, and those on this page&lt;br/&gt;
&lt;a href=&quot;http://api.mongodb.org/java/2.5-pre-/index.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://api.mongodb.org/java/2.5-pre-/index.html&lt;/a&gt;&lt;br/&gt;
certainly don&apos;t give a clue.&lt;/p&gt;</comment>
                            <comment id="23234" author="eliot" created="Mon, 7 Feb 2011 12:54:56 +0000"  >&lt;p&gt;find() doesn&apos;t actually go to the database.&lt;br/&gt;
since you can chain methods&lt;br/&gt;
.find().sort().limit().next()&lt;/p&gt;

&lt;p&gt;It would be impossible to have find() throw all possible errors.&lt;/p&gt;</comment>
                            <comment id="23233" author="datanucleus" created="Mon, 7 Feb 2011 10:58:53 +0000"  >&lt;p&gt;For the record, the log does detect this error, as &lt;br/&gt;
assertion 10068 invalid operator: $eq ns:nucleus.Person query:&lt;br/&gt;
{ firstName: &lt;/p&gt;
{ $eq: &quot;Daffy&quot; }
&lt;p&gt; } &lt;/p&gt;

&lt;p&gt;just that the Java API needs to detect it in a different place, via find().&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrgivj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>10001</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>