[JAVA-765] The com.mongodb.Mongo.close() method can return before the cleanup thread is finished Created: 21/Feb/13 Updated: 25/Jun/13 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.8.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tom Yang | Assignee: | Unassigned |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java driver : 2.8 |
||
| Description |
|
just like bug java - 306 Feb 19, 2013 10:23:20 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads |
| Comments |
| Comment by Jeffrey Yemin [ 09/Mar/13 ] |
|
No, you have to code it manually by calling Mongo.close() on all Mongo instances. That will close all the the sockets in the connection pool and stop all threads started by the Mongo constructor. |
| Comment by Tom Yang [ 22/Feb/13 ] |
|
Thanks for the replication , But I don't know how to close all Mongo connections at the same time . Is there any method could close all Mongo connections at the same time?? thanks 2013/2/22 Jeff Yemin (JIRA) <jira@mongodb.org> |
| Comment by Jeffrey Yemin [ 22/Feb/13 ] |
|
You can try posting more details of your application on the public forums. But for one thing, I wouldn't think in a web application that you would be calling Mongo.close() in a finally block. More likely when the servlet context is destroyed. See http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContextListener.html#contextDestroyed(javax.servlet.ServletContextEvent), for example. |
| Comment by Tom Yang [ 22/Feb/13 ] |
|
Thank you for the replication , I have one more question , Is there any way can be sure MongoCleaner thread errors wouldn't happen I'm sure I always add try/catch/finally to force to close mongo connection thanks ~ 2013/2/21 Jeff Yemin (JIRA) <jira@mongodb.org> |
| Comment by Jeffrey Yemin [ 21/Feb/13 ] |
|
I don't see any way that this could happen. The relevant code is here: https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/Mongo.java#L457 It seems more likely that Mongo.close() was not called. |