stack trace on programmatic shutdown from Java driver 2.6.2

365 views
Skip to first unread message

Nathan Tippy

unread,
Jun 7, 2011, 9:22:15 AM6/7/11
to mongodb-user
I have a MongoDB instance that I have stared for unit testing. At the
end before exiting my client calls the following to shutdown my test
instance of MongoDB.

//this is line 82 from the stack trace below
mongo.getDB("admin").command(new BasicDBObject("shutdown",1));

Because this is running on 127.0.0.1 the shutdown works just as
expected however after this point the Java Driver 2.6.2 spits out the
following stack trace.

Jun 7, 2011 8:17:34 AM com.mongodb.DBPortPool gotError
WARNING: emptying DBPortPool to 127.0.0.1:27001 b/c of error
java.io.EOFException
at org.bson.io.Bits.readFully(Bits.java:37)
at org.bson.io.Bits.readFully(Bits.java:28)
at com.mongodb.Response.<init>(Response.java:35)
at com.mongodb.DBPort.go(DBPort.java:110)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:207)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:296)
at com.mongodb.DB.command(DB.java:152)
at com.mongodb.DB.command(DB.java:137)
at com.ociweb.mongoDB.test.TestApp.main(TestApp.java:82)

I can prevent the driver from printing the stack trace with this
command however this is a unit test I would like to avoid suppressing
all the stacks just to mask this one problem.

Logger.getLogger("com.mongodb").setLevel(Level.OFF);

Is this a bug in the driver? Is there a better way to do this?


Scott Hernandez

unread,
Jun 7, 2011, 3:34:39 PM6/7/11
to mongod...@googlegroups.com
It is because the server shutdown closes the connection to the driver
(socket EOF). You can change your test to expect this exception and
run another command to confirm the server is down, if you really want
to.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Nathan Tippy

unread,
Jun 7, 2011, 4:13:34 PM6/7/11
to mongodb-user
Thats true but the driver its self sends a stack trace out to the log
unless I disable logging.
I don't mind dropping an expected exception however I would like the
driver to not
print the stack trace. I can stop the driver from printing the stack
trace with:

Logger.getLogger("com.mongodb").setLevel(Level.OFF);

But this feels like overkill because I could be masking other
legitimate errors.

On Jun 7, 2:34 pm, Scott Hernandez <scotthernan...@gmail.com> wrote:
> It is because the server shutdown closes the connection to the driver
> (socket EOF). You can change your test to expect this exception and
> run another command to confirm the server is down, if you really want
> to.
>

Scott Hernandez

unread,
Jun 9, 2011, 10:41:41 AM6/9/11
to mongod...@googlegroups.com
I have added an issue to follow the standard java conventions to
create loggers for each package/class so you can control this in a
more granular way. http://jira.mongodb.org/browse/JAVA-375
Reply all
Reply to author
Forward
0 new messages