{"action":"opened","issue":{"url":"https://api.github.com/repos/restx/restx/issues/193","labels_url":"https://api.github.com/repos/restx/restx/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/restx/restx/issues/193/comments","events_url":"https://api.github.com/repos/restx/restx/issues/193/events","html_url":"https://github.com/restx/restx/issues/193","id":69121664,"number":193,"title":"MongoModule should implement AutoCloseable","user":{"login":"CedricGatay","id":151195,"avatar_url":"https://avatars.githubusercontent.com/u/151195?v=3","gravatar_id":"","url":"https://api.github.com/users/CedricGatay","html_url":"https://github.com/CedricGatay","followers_url":"https://api.github.com/users/CedricGatay/followers","following_url":"https://api.github.com/users/CedricGatay/following{/other_user}","gists_url":"https://api.github.com/users/CedricGatay/gists{/gist_id}","starred_url":"https://api.github.com/users/CedricGatay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CedricGatay/subscriptions","organizations_url":"https://api.github.com/users/CedricGatay/orgs","repos_url":"https://api.github.com/users/CedricGatay/repos","events_url":"https://api.github.com/users/CedricGatay/events{/privacy}","received_events_url":"https://api.github.com/users/CedricGatay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-17T11:31:30Z","updated_at":"2015-04-17T11:31:30Z","closed_at":null,"body":"Hi there,\r\n\r\nI was facing a strange issue with one of our app, let me explain what we're doing and what was causing this : \r\n * we run job through quartz\r\n * these jobs are using injection facilities provided by restx by creating a new factory then closing it when the job is done\r\n\r\nWhen the app was running for quite a long time, we were facing OOME : can not start new native thread from `com.mongodb.Mongo`. By digging into the code I found out that `new MongoClient()` creates a new `Thread` (named MongoCleaner), the problem is that, when we close the factory, the mongoClient is not closed.\r\n\r\nThe actual fix (for this use case) consists in doing the following when closing the factory : \r\n\r\n    final MongoClient client = factory.getComponent(MongoClient.class);\r\n    if (client != null) {\r\n        client.close();\r\n    }\r\n    factory.close();\r\n\r\nDo you think it is a _real_ issue and thus should be fixed by making `MongoModule` implementing / or returning a `AutoCloseable` to do this kind of cleanup ?"}}