{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/189395874","pull_request_review_id":121260561,"id":189395874,"diff_hunk":"@@ -164,22 +167,25 @@ public synchronized AuthenticationException getAndClearAuthenticationException()\n      * Wait for metadata update until the current version is larger than the last version we know of\n      */\n     public synchronized void awaitUpdate(final int lastVersion, final long maxWaitMs) throws InterruptedException {\n-        if (maxWaitMs < 0) {\n+        if (maxWaitMs < 0)\n             throw new IllegalArgumentException(\"Max time to wait for metadata updates should not be < 0 milliseconds\");\n-        }\n+\n         long begin = System.currentTimeMillis();\n         long remainingWaitMs = maxWaitMs;\n-        while (this.version <= lastVersion) {\n+        while ((this.version <= lastVersion) && !isClosed()) {\n             AuthenticationException ex = getAndClearAuthenticationException();\n             if (ex != null)\n                 throw ex;\n             if (remainingWaitMs != 0)\n-                wait(remainingWaitMs);\n+                wait(Math.min(remainingWaitMs, 100));\n             long elapsed = System.currentTimeMillis() - begin;\n             if (elapsed >= maxWaitMs)\n                 throw new TimeoutException(\"Failed to update metadata after \" + maxWaitMs + \" ms.\");\n             remainingWaitMs = maxWaitMs - elapsed;\n         }\n+\n+        if (isClosed())\n+            throw new KafkaException(\"Requested metadata update after close\");","path":"clients/src/main/java/org/apache/kafka/clients/Metadata.java","position":50,"original_position":50,"commit_id":"2406694ff47d1fb2297cb8411e1ec6deee9598ff","original_commit_id":"2406694ff47d1fb2297cb8411e1ec6deee9598ff","user":{"login":"hachikuji","id":12502538,"avatar_url":"https://avatars3.githubusercontent.com/u/12502538?v=4","gravatar_id":"","url":"https://api.github.com/users/hachikuji","html_url":"https://github.com/hachikuji","followers_url":"https://api.github.com/users/hachikuji/followers","following_url":"https://api.github.com/users/hachikuji/following{/other_user}","gists_url":"https://api.github.com/users/hachikuji/gists{/gist_id}","starred_url":"https://api.github.com/users/hachikuji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hachikuji/subscriptions","organizations_url":"https://api.github.com/users/hachikuji/orgs","repos_url":"https://api.github.com/users/hachikuji/repos","events_url":"https://api.github.com/users/hachikuji/events{/privacy}","received_events_url":"https://api.github.com/users/hachikuji/received_events","type":"User","site_admin":false},"body":"This message seems a little low level for something which will get propagated back to the user. An alternative to consider would be to let `awaitUpdate` return a boolean indicating whether the update happened or not. That would allow us to raise an exception with a producer-specific message from `send()`.","created_at":"2018-05-18T21:19:34Z","updated_at":"2018-05-18T21:25:27Z","html_url":"https://github.com/apache/kafka/pull/5027#discussion_r189395874","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/5027","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/189395874"},"html":{"href":"https://github.com/apache/kafka/pull/5027#discussion_r189395874"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/5027"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/5027","id":188603528,"html_url":"https://github.com/apache/kafka/pull/5027","diff_url":"https://github.com/apache/kafka/pull/5027.diff","patch_url":"https://github.com/apache/kafka/pull/5027.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/5027","number":5027,"state":"open","locked":false,"title":"KAFKA-6897: Prevent producer from blocking indefinitely after close","user":{"login":"dhruvilshah3","id":14958864,"avatar_url":"https://avatars3.githubusercontent.com/u/14958864?v=4","gravatar_id":"","url":"https://api.github.com/users/dhruvilshah3","html_url":"https://github.com/dhruvilshah3","followers_url":"https://api.github.com/users/dhruvilshah3/followers","following_url":"https://api.github.com/users/dhruvilshah3/following{/other_user}","gists_url":"https://api.github.com/users/dhruvilshah3/gists{/gist_id}","starred_url":"https://api.github.com/users/dhruvilshah3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhruvilshah3/subscriptions","organizations_url":"https://api.github.com/users/dhruvilshah3/orgs","repos_url":"https://api.github.com/users/dhruvilshah3/repos","events_url":"https://api.github.com/users/dhruvilshah3/events{/privacy}","received_events_url":"https://api.github.com/users/dhruvilshah3/received_events","type":"User","site_admin":false},"body":"After successful completion of KafkaProducer#close, it is possible that an application calls KafkaProducer#send. If the send is invoked for a topic for which we do not have any metadata, the producer will block until `max.block.ms` elapses - we do not expect to receive any metadata update in this case because Sender (and NetworkClient) has already exited. It is only when RecordAccumulator#append is invoked that we notice that the producer has already been closed and throw an exception. If `max.block.ms` is set to Long.MaxValue (or a sufficiently high value in general), the producer could block awaiting metadata indefinitely.\r\n\r\nThis patch makes sure `Metadata#awaitUpdate` periodically checks if the network client has been closed, and if so bails out as soon as possible.\r\n\r\n### Committer Checklist (excluded from commit message)\r\n- [ ] Verify design and implementation \r\n- [ ] Verify test coverage and CI build status\r\n- [ ] Verify documentation (including upgrade notes)\r\n","created_at":"2018-05-17T01:46:48Z","updated_at":"2018-05-18T21:25:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2c5778f08db26b22b475377b78e9e768a477638","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/5027/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/5027/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/5027/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/2406694ff47d1fb2297cb8411e1ec6deee9598ff","head":{"label":"dhruvilshah3:producer-close","ref":"producer-close","sha":"2406694ff47d1fb2297cb8411e1ec6deee9598ff","user":{"login":"dhruvilshah3","id":14958864,"avatar_url":"https://avatars3.githubusercontent.com/u/14958864?v=4","gravatar_id":"","url":"https://api.github.com/users/dhruvilshah3","html_url":"https://github.com/dhruvilshah3","followers_url":"https://api.github.com/users/dhruvilshah3/followers","following_url":"https://api.github.com/users/dhruvilshah3/following{/other_user}","gists_url":"https://api.github.com/users/dhruvilshah3/gists{/gist_id}","starred_url":"https://api.github.com/users/dhruvilshah3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhruvilshah3/subscriptions","organizations_url":"https://api.github.com/users/dhruvilshah3/orgs","repos_url":"https://api.github.com/users/dhruvilshah3/repos","events_url":"https://api.github.com/users/dhruvilshah3/events{/privacy}","received_events_url":"https://api.github.com/users/dhruvilshah3/received_events","type":"User","site_admin":false},"repo":{"id":121815241,"name":"kafka","full_name":"dhruvilshah3/kafka","owner":{"login":"dhruvilshah3","id":14958864,"avatar_url":"https://avatars3.githubusercontent.com/u/14958864?v=4","gravatar_id":"","url":"https://api.github.com/users/dhruvilshah3","html_url":"https://github.com/dhruvilshah3","followers_url":"https://api.github.com/users/dhruvilshah3/followers","following_url":"https://api.github.com/users/dhruvilshah3/following{/other_user}","gists_url":"https://api.github.com/users/dhruvilshah3/gists{/gist_id}","starred_url":"https://api.github.com/users/dhruvilshah3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhruvilshah3/subscriptions","organizations_url":"https://api.github.com/users/dhruvilshah3/orgs","repos_url":"https://api.github.com/users/dhruvilshah3/repos","events_url":"https://api.github.com/users/dhruvilshah3/events{/privacy}","received_events_url":"https://api.github.com/users/dhruvilshah3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dhruvilshah3/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/dhruvilshah3/kafka","forks_url":"https://api.github.com/repos/dhruvilshah3/kafka/forks","keys_url":"https://api.github.com/repos/dhruvilshah3/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dhruvilshah3/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dhruvilshah3/kafka/teams","hooks_url":"https://api.github.com/repos/dhruvilshah3/kafka/hooks","issue_events_url":"https://api.github.com/repos/dhruvilshah3/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/dhruvilshah3/kafka/events","assignees_url":"https://api.github.com/repos/dhruvilshah3/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/dhruvilshah3/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/dhruvilshah3/kafka/tags","blobs_url":"https://api.github.com/repos/dhruvilshah3/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dhruvilshah3/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dhruvilshah3/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/dhruvilshah3/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dhruvilshah3/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/dhruvilshah3/kafka/languages","stargazers_url":"https://api.github.com/repos/dhruvilshah3/kafka/stargazers","contributors_url":"https://api.github.com/repos/dhruvilshah3/kafka/contributors","subscribers_url":"https://api.github.com/repos/dhruvilshah3/kafka/subscribers","subscription_url":"https://api.github.com/repos/dhruvilshah3/kafka/subscription","commits_url":"https://api.github.com/repos/dhruvilshah3/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/dhruvilshah3/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/dhruvilshah3/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/dhruvilshah3/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/dhruvilshah3/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/dhruvilshah3/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dhruvilshah3/kafka/merges","archive_url":"https://api.github.com/repos/dhruvilshah3/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dhruvilshah3/kafka/downloads","issues_url":"https://api.github.com/repos/dhruvilshah3/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/dhruvilshah3/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/dhruvilshah3/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/dhruvilshah3/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dhruvilshah3/kafka/labels{/name}","releases_url":"https://api.github.com/repos/dhruvilshah3/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/dhruvilshah3/kafka/deployments","created_at":"2018-02-17T00:27:42Z","updated_at":"2018-05-17T21:13:58Z","pushed_at":"2018-05-18T21:19:24Z","git_url":"git://github.com/dhruvilshah3/kafka.git","ssh_url":"git@github.com:dhruvilshah3/kafka.git","clone_url":"https://github.com/dhruvilshah3/kafka.git","svn_url":"https://github.com/dhruvilshah3/kafka","homepage":null,"size":65276,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"6b8e79b13780d4e91d79325e0bf9f1c8df191176","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":2211243,"name":"kafka","full_name":"apache/kafka","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2018-05-18T20:31:55Z","pushed_at":"2018-05-18T21:19:26Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":65518,"stargazers_count":8366,"watchers_count":8366,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4862,"mirror_url":null,"archived":false,"open_issues_count":459,"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":4862,"open_issues":459,"watchers":8366,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/5027"},"html":{"href":"https://github.com/apache/kafka/pull/5027"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/5027"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/5027/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/5027/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/5027/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/2406694ff47d1fb2297cb8411e1ec6deee9598ff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hachikuji"}}