I am trying to use Mongo tailable cursor to fetch docs from a capped
collection.
I use mongo-java driver ver. 2.1. and constantly receive a
StackOverflowError.
Below are the code snippet reproducing the error, the stack trace, and
capped collection stats from mongo shell.
Am I doing something wrong?
db version v1.6.1, pdfile version 4.5
git hash: c5f5f9a4f3b515dfd5272d373093fd4fd58c95d9
sys info: Linux xxxx 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28
06:21:40 UTC 2010 x86_64 BOOST_LIB_VERSION=1_40
----------------------------------------------
package test;
import com.mongodb.*;
public class Test {
public static void main(String[] args) throws Exception {
Mongo mongo = new Mongo("localhost");
DB db = mongo.getDB("test");
DBCollection coll = db.getCollection("mycoll");
DBCursor cur = coll.find().sort(new BasicDBObject("$natural", 1))
.addOption(Bytes.QUERYOPTION_TAILABLE);
while (cur.hasNext()) {
System.out.println(cur.next());
}
}
}
And here is the stacktrace:
Exception in thread "main" java.lang.StackOverflowError
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at org.bson.io.Bits.readFully(Bits.java:30)
at com.mongodb.Response.<init>(Response.java:34)
at com.mongodb.DBPort.go(DBPort.java:85)
at com.mongodb.DBPort.call(DBPort.java:56)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:186)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:173)
at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:328)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:311)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:312)
<...>
Collection 'mycoll' stats
{
"ns" : "test.mycoll",
"count" : 200,
"size" : 7200,
"avgObjSize" : 36,
"storageSize" : 1000192,
"numExtents" : 1,
"nindexes" : 0,
"lastExtentSize" : 1000192,
"paddingFactor" : 1,
"flags" : 0,
"totalIndexSize" : 0,
"indexSizes" : {
},
"capped" : 1,
"max" :
2147483647,
"ok" : 1
}