<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:37 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-155] StackOverflowError when fetching a tailable cursor after getting the last document</title>
                <link>https://jira.mongodb.org/browse/JAVA-155</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;When iterating through a capped collection via a tailable cursor, I get a StackOverflowError as soon as the cursor reaches the end of the collection.&lt;/p&gt;

&lt;p&gt;Error can be reproduced by running the code below:&lt;/p&gt;

&lt;p&gt;package test;&lt;/p&gt;

&lt;p&gt;import com.mongodb.*;&lt;/p&gt;

&lt;p&gt;public class Test {&lt;/p&gt;

&lt;p&gt;  public static void main(String[] args) throws Exception {&lt;/p&gt;

&lt;p&gt;    Mongo mongo = new Mongo(&quot;localhost&quot;);&lt;br/&gt;
    DB db = mongo.getDB(&quot;test&quot;);&lt;br/&gt;
    DBCollection coll = db.getCollection(&quot;mycoll&quot;);&lt;/p&gt;

&lt;p&gt;    DBCursor cur = coll.find().sort(new BasicDBObject(&quot;$natural&quot;, 1))&lt;br/&gt;
        .addOption(Bytes.QUERYOPTION_TAILABLE);&lt;/p&gt;

&lt;p&gt;    while (cur.hasNext()) &lt;/p&gt;
{
      System.out.println(cur.next());
    }
&lt;p&gt;  }&lt;br/&gt;
} &lt;/p&gt;


&lt;p&gt;After reading the last document, cursor.hasNext() will result in a StackOverflowError. Here is the stack trace:&lt;/p&gt;

&lt;p&gt;Exception in thread &quot;main&quot; java.lang.StackOverflowError&lt;br/&gt;
        at java.net.SocketInputStream.read(SocketInputStream.java:129)&lt;br/&gt;
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)&lt;br/&gt;
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)&lt;br/&gt;
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)&lt;br/&gt;
        at org.bson.io.Bits.readFully(Bits.java:30)&lt;br/&gt;
        at com.mongodb.Response.&amp;lt;init&amp;gt;(Response.java:34)&lt;br/&gt;
        at com.mongodb.DBPort.go(DBPort.java:85)&lt;br/&gt;
        at com.mongodb.DBPort.call(DBPort.java:56)&lt;br/&gt;
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)&lt;br/&gt;
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:173)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:328)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:311)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)&lt;br/&gt;
              &amp;lt;...&amp;gt;&lt;/p&gt;


&lt;p&gt;The problem is shadowed if a cursor is created with QUERYOPTION_AWAITDATA option. The stack will nevertheless fill up because of recursion, but much slower.&lt;/p&gt;</description>
                <environment>Sun Java 1.6_20 (64bit)&lt;br/&gt;
&lt;br/&gt;
db version v1.6.1, pdfile version 4.5&lt;br/&gt;
git hash: c5f5f9a4f3b515dfd5272d373093fd4fd58c95d9&lt;br/&gt;
sys info: Linux xxxx 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28&lt;br/&gt;
06:21:40 UTC 2010 x86_64 BOOST_LIB_VERSION=1_40 </environment>
        <key id="12914">JAVA-155</key>
            <summary>StackOverflowError when fetching a tailable cursor after getting the last document</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="shinderuk">Sergey Shinderuk</reporter>
                        <labels>
                    </labels>
                <created>Wed, 25 Aug 2010 18:59:07 +0000</created>
                <updated>Fri, 29 Oct 2010 02:49:59 +0000</updated>
                            <resolved>Wed, 15 Sep 2010 15:02:56 +0000</resolved>
                                    <version>2.1</version>
                                    <fixVersion>2.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="18424" author="auto" created="Wed, 22 Sep 2010 14:52:06 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;erh&apos;, &apos;name&apos;: &apos;Eliot Horowitz&apos;, &apos;email&apos;: &apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: switch from recursion to while loop to avoid inf. recursion &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-155&quot; title=&quot;StackOverflowError when fetching a tailable cursor after getting the last document&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-155&quot;&gt;&lt;del&gt;JAVA-155&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/commit/c3e2a75f02778a40b9869bbb21d9abfeb03bb694&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/commit/c3e2a75f02778a40b9869bbb21d9abfeb03bb694&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="18217" author="scotthernandez" created="Wed, 15 Sep 2010 15:02:56 +0000"  >&lt;p&gt;&lt;a href=&quot;http://github.com/scotthernandez/mongo-java-driver/commit/66952e18ea560a4befbd07e0a48c852ec9040084&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/scotthernandez/mongo-java-driver/commit/66952e18ea560a4befbd07e0a48c852ec9040084&lt;/a&gt;&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|hrhcxj:</customfieldvalue>

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