{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/comments/204257558","pull_request_review_id":139303895,"id":204257558,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDI1NzU1OA==","diff_hunk":"@@ -0,0 +1,72 @@\n+/*\n+ * Copyright 2018 Google LLC. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package com.google.cloud.tools.jib.http;\n+\n+import java.io.Closeable;\n+import java.io.IOException;\n+import java.net.ServerSocket;\n+import java.net.Socket;\n+import java.nio.charset.StandardCharsets;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.Semaphore;\n+\n+/** Simple local web server for testing. */\n+class TestWebServer implements Closeable {\n+\n+  private final ServerSocket serverSocket;\n+  private final List<Socket> socketsToClose = new ArrayList<>();\n+  private final ExecutorService executorService = Executors.newSingleThreadExecutor();\n+  private final Semaphore threadStarted = new Semaphore(0);\n+\n+  TestWebServer() throws IOException, InterruptedException {\n+    serverSocket = new ServerSocket(0);\n+    executorService.submit(this::serve200);\n+    threadStarted.acquire();\n+  }\n+\n+  String getEndpoint() {\n+    String host = serverSocket.getInetAddress().getHostAddress();\n+    return \"http://\" + host + \":\" + serverSocket.getLocalPort();\n+  }\n+\n+  @Override\n+  public void close() throws IOException {\n+    serverSocket.close();\n+    for (Socket socket : socketsToClose) {\n+      try (Socket toClose = socket) {\n+      } catch (IOException ex) {\n+      }\n+    }\n+    executorService.shutdown();\n+  }\n+\n+  private Void serve200() throws IOException {\n+    threadStarted.release();\n+    while (true) {\n+      Socket socket = serverSocket.accept();\n+      socketsToClose.add(socket);","path":"jib-core/src/test/java/com/google/cloud/tools/jib/http/TestWebServer.java","position":64,"original_position":64,"commit_id":"8d98812bbfba65872438e68f09b5fab0f1cbfa23","original_commit_id":"8d98812bbfba65872438e68f09b5fab0f1cbfa23","user":{"login":"chanseokoh","id":10523105,"node_id":"MDQ6VXNlcjEwNTIzMTA1","avatar_url":"https://avatars2.githubusercontent.com/u/10523105?v=4","gravatar_id":"","url":"https://api.github.com/users/chanseokoh","html_url":"https://github.com/chanseokoh","followers_url":"https://api.github.com/users/chanseokoh/followers","following_url":"https://api.github.com/users/chanseokoh/following{/other_user}","gists_url":"https://api.github.com/users/chanseokoh/gists{/gist_id}","starred_url":"https://api.github.com/users/chanseokoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanseokoh/subscriptions","organizations_url":"https://api.github.com/users/chanseokoh/orgs","repos_url":"https://api.github.com/users/chanseokoh/repos","events_url":"https://api.github.com/users/chanseokoh/events{/privacy}","received_events_url":"https://api.github.com/users/chanseokoh/received_events","type":"User","site_admin":false},"body":"It's safe to call `close()` multiple times on a socket or call it on a closed socket. Probably it is safe on almost all `Closeable` classes.\r\n\r\n(And I don't think I get the out-of-bound exception. The enhanced `for` loop never throws it.)","created_at":"2018-07-22T22:39:28Z","updated_at":"2018-07-22T22:39:28Z","html_url":"https://github.com/GoogleContainerTools/jib/pull/687#discussion_r204257558","pull_request_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/comments/204257558"},"html":{"href":"https://github.com/GoogleContainerTools/jib/pull/687#discussion_r204257558"},"pull_request":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687"}},"in_reply_to_id":204251664},"pull_request":{"url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687","id":202960485,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyOTYwNDg1","html_url":"https://github.com/GoogleContainerTools/jib/pull/687","diff_url":"https://github.com/GoogleContainerTools/jib/pull/687.diff","patch_url":"https://github.com/GoogleContainerTools/jib/pull/687.patch","issue_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/687","number":687,"state":"open","locked":false,"title":"Prevent sending multiple requests in a connection","user":{"login":"chanseokoh","id":10523105,"node_id":"MDQ6VXNlcjEwNTIzMTA1","avatar_url":"https://avatars2.githubusercontent.com/u/10523105?v=4","gravatar_id":"","url":"https://api.github.com/users/chanseokoh","html_url":"https://github.com/chanseokoh","followers_url":"https://api.github.com/users/chanseokoh/followers","following_url":"https://api.github.com/users/chanseokoh/following{/other_user}","gists_url":"https://api.github.com/users/chanseokoh/gists{/gist_id}","starred_url":"https://api.github.com/users/chanseokoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanseokoh/subscriptions","organizations_url":"https://api.github.com/users/chanseokoh/orgs","repos_url":"https://api.github.com/users/chanseokoh/repos","events_url":"https://api.github.com/users/chanseokoh/events{/privacy}","received_events_url":"https://api.github.com/users/chanseokoh/received_events","type":"User","site_admin":false},"body":"Fixes #686.\r\n\r\nHad to remove the `@Mock` annotation from the `httpResponse` field, since otherwise it is injected into `Connection` by `@InjectMocks`.\r\n\r\nAlso added another test class for `Connection` that interacts with a local web server.","created_at":"2018-07-20T21:28:57Z","updated_at":"2018-07-22T22:39:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9644c28bb1d8af31cec5b6b770649887cb5a482","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687/commits","review_comments_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687/comments","review_comment_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/687/comments","statuses_url":"https://api.github.com/repos/GoogleContainerTools/jib/statuses/8d98812bbfba65872438e68f09b5fab0f1cbfa23","head":{"label":"GoogleContainerTools:chanseok-code","ref":"chanseok-code","sha":"8d98812bbfba65872438e68f09b5fab0f1cbfa23","user":{"login":"GoogleContainerTools","id":38444003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NDQ0MDAz","avatar_url":"https://avatars1.githubusercontent.com/u/38444003?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleContainerTools","html_url":"https://github.com/GoogleContainerTools","followers_url":"https://api.github.com/users/GoogleContainerTools/followers","following_url":"https://api.github.com/users/GoogleContainerTools/following{/other_user}","gists_url":"https://api.github.com/users/GoogleContainerTools/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleContainerTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleContainerTools/subscriptions","organizations_url":"https://api.github.com/users/GoogleContainerTools/orgs","repos_url":"https://api.github.com/users/GoogleContainerTools/repos","events_url":"https://api.github.com/users/GoogleContainerTools/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleContainerTools/received_events","type":"Organization","site_admin":false},"repo":{"id":118497841,"node_id":"MDEwOlJlcG9zaXRvcnkxMTg0OTc4NDE=","name":"jib","full_name":"GoogleContainerTools/jib","owner":{"login":"GoogleContainerTools","id":38444003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NDQ0MDAz","avatar_url":"https://avatars1.githubusercontent.com/u/38444003?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleContainerTools","html_url":"https://github.com/GoogleContainerTools","followers_url":"https://api.github.com/users/GoogleContainerTools/followers","following_url":"https://api.github.com/users/GoogleContainerTools/following{/other_user}","gists_url":"https://api.github.com/users/GoogleContainerTools/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleContainerTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleContainerTools/subscriptions","organizations_url":"https://api.github.com/users/GoogleContainerTools/orgs","repos_url":"https://api.github.com/users/GoogleContainerTools/repos","events_url":"https://api.github.com/users/GoogleContainerTools/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleContainerTools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleContainerTools/jib","description":":sailboat: Build container images for your Java applications.","fork":false,"url":"https://api.github.com/repos/GoogleContainerTools/jib","forks_url":"https://api.github.com/repos/GoogleContainerTools/jib/forks","keys_url":"https://api.github.com/repos/GoogleContainerTools/jib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleContainerTools/jib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleContainerTools/jib/teams","hooks_url":"https://api.github.com/repos/GoogleContainerTools/jib/hooks","issue_events_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleContainerTools/jib/events","assignees_url":"https://api.github.com/repos/GoogleContainerTools/jib/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleContainerTools/jib/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleContainerTools/jib/tags","blobs_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleContainerTools/jib/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleContainerTools/jib/languages","stargazers_url":"https://api.github.com/repos/GoogleContainerTools/jib/stargazers","contributors_url":"https://api.github.com/repos/GoogleContainerTools/jib/contributors","subscribers_url":"https://api.github.com/repos/GoogleContainerTools/jib/subscribers","subscription_url":"https://api.github.com/repos/GoogleContainerTools/jib/subscription","commits_url":"https://api.github.com/repos/GoogleContainerTools/jib/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleContainerTools/jib/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleContainerTools/jib/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleContainerTools/jib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleContainerTools/jib/merges","archive_url":"https://api.github.com/repos/GoogleContainerTools/jib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleContainerTools/jib/downloads","issues_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleContainerTools/jib/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleContainerTools/jib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleContainerTools/jib/labels{/name}","releases_url":"https://api.github.com/repos/GoogleContainerTools/jib/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleContainerTools/jib/deployments","created_at":"2018-01-22T18:30:43Z","updated_at":"2018-07-22T17:08:58Z","pushed_at":"2018-07-22T19:01:20Z","git_url":"git://github.com/GoogleContainerTools/jib.git","ssh_url":"git@github.com:GoogleContainerTools/jib.git","clone_url":"https://github.com/GoogleContainerTools/jib.git","svn_url":"https://github.com/GoogleContainerTools/jib","homepage":"","size":3170,"stargazers_count":3518,"watchers_count":3518,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":237,"mirror_url":null,"archived":false,"open_issues_count":88,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":237,"open_issues":88,"watchers":3518,"default_branch":"master"}},"base":{"label":"GoogleContainerTools:master","ref":"master","sha":"dea7a2ae244629a5f97ee1fec7be5df49bf07156","user":{"login":"GoogleContainerTools","id":38444003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NDQ0MDAz","avatar_url":"https://avatars1.githubusercontent.com/u/38444003?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleContainerTools","html_url":"https://github.com/GoogleContainerTools","followers_url":"https://api.github.com/users/GoogleContainerTools/followers","following_url":"https://api.github.com/users/GoogleContainerTools/following{/other_user}","gists_url":"https://api.github.com/users/GoogleContainerTools/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleContainerTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleContainerTools/subscriptions","organizations_url":"https://api.github.com/users/GoogleContainerTools/orgs","repos_url":"https://api.github.com/users/GoogleContainerTools/repos","events_url":"https://api.github.com/users/GoogleContainerTools/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleContainerTools/received_events","type":"Organization","site_admin":false},"repo":{"id":118497841,"node_id":"MDEwOlJlcG9zaXRvcnkxMTg0OTc4NDE=","name":"jib","full_name":"GoogleContainerTools/jib","owner":{"login":"GoogleContainerTools","id":38444003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NDQ0MDAz","avatar_url":"https://avatars1.githubusercontent.com/u/38444003?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleContainerTools","html_url":"https://github.com/GoogleContainerTools","followers_url":"https://api.github.com/users/GoogleContainerTools/followers","following_url":"https://api.github.com/users/GoogleContainerTools/following{/other_user}","gists_url":"https://api.github.com/users/GoogleContainerTools/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleContainerTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleContainerTools/subscriptions","organizations_url":"https://api.github.com/users/GoogleContainerTools/orgs","repos_url":"https://api.github.com/users/GoogleContainerTools/repos","events_url":"https://api.github.com/users/GoogleContainerTools/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleContainerTools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleContainerTools/jib","description":":sailboat: Build container images for your Java applications.","fork":false,"url":"https://api.github.com/repos/GoogleContainerTools/jib","forks_url":"https://api.github.com/repos/GoogleContainerTools/jib/forks","keys_url":"https://api.github.com/repos/GoogleContainerTools/jib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleContainerTools/jib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleContainerTools/jib/teams","hooks_url":"https://api.github.com/repos/GoogleContainerTools/jib/hooks","issue_events_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleContainerTools/jib/events","assignees_url":"https://api.github.com/repos/GoogleContainerTools/jib/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleContainerTools/jib/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleContainerTools/jib/tags","blobs_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleContainerTools/jib/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleContainerTools/jib/languages","stargazers_url":"https://api.github.com/repos/GoogleContainerTools/jib/stargazers","contributors_url":"https://api.github.com/repos/GoogleContainerTools/jib/contributors","subscribers_url":"https://api.github.com/repos/GoogleContainerTools/jib/subscribers","subscription_url":"https://api.github.com/repos/GoogleContainerTools/jib/subscription","commits_url":"https://api.github.com/repos/GoogleContainerTools/jib/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleContainerTools/jib/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleContainerTools/jib/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleContainerTools/jib/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleContainerTools/jib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleContainerTools/jib/merges","archive_url":"https://api.github.com/repos/GoogleContainerTools/jib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleContainerTools/jib/downloads","issues_url":"https://api.github.com/repos/GoogleContainerTools/jib/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleContainerTools/jib/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleContainerTools/jib/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleContainerTools/jib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleContainerTools/jib/labels{/name}","releases_url":"https://api.github.com/repos/GoogleContainerTools/jib/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleContainerTools/jib/deployments","created_at":"2018-01-22T18:30:43Z","updated_at":"2018-07-22T17:08:58Z","pushed_at":"2018-07-22T19:01:20Z","git_url":"git://github.com/GoogleContainerTools/jib.git","ssh_url":"git@github.com:GoogleContainerTools/jib.git","clone_url":"https://github.com/GoogleContainerTools/jib.git","svn_url":"https://github.com/GoogleContainerTools/jib","homepage":"","size":3170,"stargazers_count":3518,"watchers_count":3518,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":237,"mirror_url":null,"archived":false,"open_issues_count":88,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":237,"open_issues":88,"watchers":3518,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687"},"html":{"href":"https://github.com/GoogleContainerTools/jib/pull/687"},"issue":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/issues/687"},"comments":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/issues/687/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/pulls/687/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleContainerTools/jib/statuses/8d98812bbfba65872438e68f09b5fab0f1cbfa23"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"chanseokoh"}}