{"action":"created","comment":{"url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/comments/167542702","pull_request_review_id":95775434,"id":167542702,"diff_hunk":"@@ -102,6 +103,40 @@ class AsyncQueryBatchCursorFunctionalSpecification extends OperationFunctionalSp\n         !nextBatch()\n     }\n \n+    def 'should not retain connection and source after cursor is exhausted on first batch'() {\n+        given:\n+        cursor = new AsyncQueryBatchCursor<Document>(executeQuery(), 0, 0, 0, new DocumentCodec(), connectionSource, connection)\n+\n+        when:\n+        nextBatch()\n+\n+        then:\n+        connection.count == 1\n+        connectionSource.count == 1\n+    }\n+\n+    def 'should not retain connection and source after cursor is exhausted on getMore'() {\n+        given:\n+        cursor = new AsyncQueryBatchCursor<Document>(executeQuery(1, 0), 1, 1, 0, new DocumentCodec(), connectionSource, connection)\n+\n+        when:\n+        nextBatch()\n+\n+        then:\n+        getReferenceCountAfterTimeout(connection, 1)","path":"driver-core/src/test/functional/com/mongodb/operation/AsyncQueryBatchCursorFunctionalSpecification.groovy","position":null,"original_position":32,"commit_id":"6640ab49fd5e75a3f106ec2850567ef692236390","original_commit_id":"4e98acf5e3e5f4c951e44dd4b87eecc37e12fb71","user":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"body":"Good catch.  Done.","created_at":"2018-02-12T12:38:59Z","updated_at":"2018-02-12T12:38:59Z","html_url":"https://github.com/jyemin/mongo-java-driver/pull/110#discussion_r167542702","pull_request_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/comments/167542702"},"html":{"href":"https://github.com/jyemin/mongo-java-driver/pull/110#discussion_r167542702"},"pull_request":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110"}},"in_reply_to_id":167533961},"pull_request":{"url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110","id":168466154,"html_url":"https://github.com/jyemin/mongo-java-driver/pull/110","diff_url":"https://github.com/jyemin/mongo-java-driver/pull/110.diff","patch_url":"https://github.com/jyemin/mongo-java-driver/pull/110.patch","issue_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/110","number":110,"state":"open","locked":false,"title":"JAVA-2778","user":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"body":"Where there's smoke there's fire.  Turns out there are multiple leakes to plug, including\r\n\r\n* QueryBatchCursor: ensure that connection source (and thus the session it's retaining) is released as early as possible, to minimize the effect of unclosed cursors on the number of sessions created\r\n* AsyncQueryBatchCursor: same as QueryBatchCursor, but the code to do it is more complicated\r\n* ListDatabasesOperation: release connection source asynchronously in addition to connection\r\n* ChangeStreamBatchCursor: release connection source after a retry\r\n* AsyncChangeStreamBatchCursor: release connection source after a retry\r\n* MixedBulkWriteOperation: release connection source after a retry\r\n\r\nExcept for the first two, all these bugs were found by adding additional checks on test cleanup that throw exceptions if binding reference counts (for core) and server session pool in use counts (for high) have not dropped to the expected target count.\r\n\r\nPatch build: https://evergreen.mongodb.com/version/5a806fc5e3c331673c428b06","created_at":"2018-02-11T18:17:25Z","updated_at":"2018-02-12T12:38:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a60a7b8a12796836cff9e2e01ea440f78e1eb8c","assignee":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"assignees":[{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"rstam","id":275022,"avatar_url":"https://avatars0.githubusercontent.com/u/275022?v=4","gravatar_id":"","url":"https://api.github.com/users/rstam","html_url":"https://github.com/rstam","followers_url":"https://api.github.com/users/rstam/followers","following_url":"https://api.github.com/users/rstam/following{/other_user}","gists_url":"https://api.github.com/users/rstam/gists{/gist_id}","starred_url":"https://api.github.com/users/rstam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstam/subscriptions","organizations_url":"https://api.github.com/users/rstam/orgs","repos_url":"https://api.github.com/users/rstam/repos","events_url":"https://api.github.com/users/rstam/events{/privacy}","received_events_url":"https://api.github.com/users/rstam/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110/commits","review_comments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110/comments","review_comment_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/110/comments","statuses_url":"https://api.github.com/repos/jyemin/mongo-java-driver/statuses/6640ab49fd5e75a3f106ec2850567ef692236390","head":{"label":"jyemin:j2778","ref":"j2778","sha":"6640ab49fd5e75a3f106ec2850567ef692236390","user":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"repo":{"id":2603134,"name":"mongo-java-driver","full_name":"jyemin/mongo-java-driver","owner":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jyemin/mongo-java-driver","description":"The Java driver for MongoDB","fork":true,"url":"https://api.github.com/repos/jyemin/mongo-java-driver","forks_url":"https://api.github.com/repos/jyemin/mongo-java-driver/forks","keys_url":"https://api.github.com/repos/jyemin/mongo-java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jyemin/mongo-java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jyemin/mongo-java-driver/teams","hooks_url":"https://api.github.com/repos/jyemin/mongo-java-driver/hooks","issue_events_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/jyemin/mongo-java-driver/events","assignees_url":"https://api.github.com/repos/jyemin/mongo-java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/jyemin/mongo-java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/jyemin/mongo-java-driver/tags","blobs_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jyemin/mongo-java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/jyemin/mongo-java-driver/languages","stargazers_url":"https://api.github.com/repos/jyemin/mongo-java-driver/stargazers","contributors_url":"https://api.github.com/repos/jyemin/mongo-java-driver/contributors","subscribers_url":"https://api.github.com/repos/jyemin/mongo-java-driver/subscribers","subscription_url":"https://api.github.com/repos/jyemin/mongo-java-driver/subscription","commits_url":"https://api.github.com/repos/jyemin/mongo-java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/jyemin/mongo-java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/jyemin/mongo-java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jyemin/mongo-java-driver/merges","archive_url":"https://api.github.com/repos/jyemin/mongo-java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jyemin/mongo-java-driver/downloads","issues_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/jyemin/mongo-java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/jyemin/mongo-java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jyemin/mongo-java-driver/labels{/name}","releases_url":"https://api.github.com/repos/jyemin/mongo-java-driver/releases{/id}","deployments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/deployments","created_at":"2011-10-19T00:37:59Z","updated_at":"2017-06-28T22:05:29Z","pushed_at":"2018-02-12T12:38:24Z","git_url":"git://github.com/jyemin/mongo-java-driver.git","ssh_url":"git@github.com:jyemin/mongo-java-driver.git","clone_url":"https://github.com/jyemin/mongo-java-driver.git","svn_url":"https://github.com/jyemin/mongo-java-driver","homepage":"https://mongodb.github.io/mongo-java-driver","size":48717,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"jyemin:3.6.x","ref":"3.6.x","sha":"4d90becbe5725a0b42dfbbea8c2c9e9dd1eb359e","user":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"repo":{"id":2603134,"name":"mongo-java-driver","full_name":"jyemin/mongo-java-driver","owner":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars1.githubusercontent.com/u/1111546?v=4","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jyemin/mongo-java-driver","description":"The Java driver for MongoDB","fork":true,"url":"https://api.github.com/repos/jyemin/mongo-java-driver","forks_url":"https://api.github.com/repos/jyemin/mongo-java-driver/forks","keys_url":"https://api.github.com/repos/jyemin/mongo-java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jyemin/mongo-java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jyemin/mongo-java-driver/teams","hooks_url":"https://api.github.com/repos/jyemin/mongo-java-driver/hooks","issue_events_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/jyemin/mongo-java-driver/events","assignees_url":"https://api.github.com/repos/jyemin/mongo-java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/jyemin/mongo-java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/jyemin/mongo-java-driver/tags","blobs_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jyemin/mongo-java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/jyemin/mongo-java-driver/languages","stargazers_url":"https://api.github.com/repos/jyemin/mongo-java-driver/stargazers","contributors_url":"https://api.github.com/repos/jyemin/mongo-java-driver/contributors","subscribers_url":"https://api.github.com/repos/jyemin/mongo-java-driver/subscribers","subscription_url":"https://api.github.com/repos/jyemin/mongo-java-driver/subscription","commits_url":"https://api.github.com/repos/jyemin/mongo-java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/jyemin/mongo-java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/jyemin/mongo-java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/jyemin/mongo-java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jyemin/mongo-java-driver/merges","archive_url":"https://api.github.com/repos/jyemin/mongo-java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jyemin/mongo-java-driver/downloads","issues_url":"https://api.github.com/repos/jyemin/mongo-java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/jyemin/mongo-java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/jyemin/mongo-java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jyemin/mongo-java-driver/labels{/name}","releases_url":"https://api.github.com/repos/jyemin/mongo-java-driver/releases{/id}","deployments_url":"https://api.github.com/repos/jyemin/mongo-java-driver/deployments","created_at":"2011-10-19T00:37:59Z","updated_at":"2017-06-28T22:05:29Z","pushed_at":"2018-02-12T12:38:24Z","git_url":"git://github.com/jyemin/mongo-java-driver.git","ssh_url":"git@github.com:jyemin/mongo-java-driver.git","clone_url":"https://github.com/jyemin/mongo-java-driver.git","svn_url":"https://github.com/jyemin/mongo-java-driver","homepage":"https://mongodb.github.io/mongo-java-driver","size":48717,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110"},"html":{"href":"https://github.com/jyemin/mongo-java-driver/pull/110"},"issue":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/110"},"comments":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/jyemin/mongo-java-driver/statuses/6640ab49fd5e75a3f106ec2850567ef692236390"}},"author_association":"OWNER"}}
{"actor":{"display_login":"jyemin"}}