{"action":"created","comment":{"url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/comments/58292014","id":58292014,"diff_hunk":"@@ -0,0 +1,111 @@\n+import java.io.*;\n+import java.net.Socket;\n+import java.util.ArrayList;\n+\n+/**\n+ * Created by n_buga on 13.03.16.\n+ */\n+public class Connection implements AutoCloseable {\n+    private Socket socket;\n+    private Boolean isClosed;\n+    private DataOutputStream out;\n+    private DataInputStream in;\n+\n+    public boolean isClosed() {\n+        return isClosed;\n+    }\n+\n+    public Connection(Socket socket) throws IOException {\n+        this.socket = socket;\n+        out = new DataOutputStream(socket.getOutputStream());\n+        in = new DataInputStream(socket.getInputStream());\n+        isClosed = false;\n+    }\n+\n+    public synchronized void close() {\n+        if (isClosed) {\n+            return;\n+        }\n+        try {\n+            socket.close();\n+            if (out != null) out.close();\n+            if (in != null) in.close();\n+        } catch (IOException ignored) { }\n+        isClosed = true;\n+    }\n+\n+    public void waitUntilClosed() {\n+        final int delay = 100;\n+        try {\n+            while (in != null && in.available() > 0) {\n+                try {\n+                    Thread.sleep(delay);\n+                } catch (InterruptedException ignored) {\n+                }\n+            }\n+        } catch (IOException ignored) {","path":"src/main/java/Connection.java","position":null,"original_position":46,"commit_id":"4fcce2019000ba10a399561cb19e555cbd0eff51","original_commit_id":"dc3ae0fd000156269878568afb172bdedc9c82ff","user":{"login":"dzharkov","id":863207,"avatar_url":"https://avatars.githubusercontent.com/u/863207?v=3","gravatar_id":"","url":"https://api.github.com/users/dzharkov","html_url":"https://github.com/dzharkov","followers_url":"https://api.github.com/users/dzharkov/followers","following_url":"https://api.github.com/users/dzharkov/following{/other_user}","gists_url":"https://api.github.com/users/dzharkov/gists{/gist_id}","starred_url":"https://api.github.com/users/dzharkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzharkov/subscriptions","organizations_url":"https://api.github.com/users/dzharkov/orgs","repos_url":"https://api.github.com/users/dzharkov/repos","events_url":"https://api.github.com/users/dzharkov/events{/privacy}","received_events_url":"https://api.github.com/users/dzharkov/received_events","type":"User","site_admin":false},"body":"Вообще IOException означает, что произошло что-то очень плохое, файл умер, например.\r\nА ты просто выходишь из цикла.\r\nВообще семантика этого метода кажется очень подозрительной.\r\nМожет проще переопределить метод `close` у возвращаемого потока, чтобы он закрывал сокеты?","created_at":"2016-04-02T11:18:11Z","updated_at":"2016-04-02T11:18:11Z","html_url":"https://github.com/java-course-au/assignments-2/pull/44#discussion_r58292014","pull_request_url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/comments/58292014"},"html":{"href":"https://github.com/java-course-au/assignments-2/pull/44#discussion_r58292014"},"pull_request":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44","id":63474359,"html_url":"https://github.com/java-course-au/assignments-2/pull/44","diff_url":"https://github.com/java-course-au/assignments-2/pull/44.diff","patch_url":"https://github.com/java-course-au/assignments-2/pull/44.patch","issue_url":"https://api.github.com/repos/java-course-au/assignments-2/issues/44","number":44,"state":"open","locked":false,"title":"Simple ftp, ДЗ_03, группа 1, Бугакова Надежда","user":{"login":"N-buga","id":10629368,"avatar_url":"https://avatars.githubusercontent.com/u/10629368?v=3","gravatar_id":"","url":"https://api.github.com/users/N-buga","html_url":"https://github.com/N-buga","followers_url":"https://api.github.com/users/N-buga/followers","following_url":"https://api.github.com/users/N-buga/following{/other_user}","gists_url":"https://api.github.com/users/N-buga/gists{/gist_id}","starred_url":"https://api.github.com/users/N-buga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-buga/subscriptions","organizations_url":"https://api.github.com/users/N-buga/orgs","repos_url":"https://api.github.com/users/N-buga/repos","events_url":"https://api.github.com/users/N-buga/events{/privacy}","received_events_url":"https://api.github.com/users/N-buga/received_events","type":"User","site_admin":false},"body":"Add requirements. @dzharkov ","created_at":"2016-03-19T18:07:05Z","updated_at":"2016-04-02T11:18:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0708137024b92a5dc96eb5fddd62cb40f8323450","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44/commits","review_comments_url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44/comments","review_comment_url":"https://api.github.com/repos/java-course-au/assignments-2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/java-course-au/assignments-2/issues/44/comments","statuses_url":"https://api.github.com/repos/java-course-au/assignments-2/statuses/4fcce2019000ba10a399561cb19e555cbd0eff51","head":{"label":"N-buga:simpleFTP","ref":"simpleFTP","sha":"4fcce2019000ba10a399561cb19e555cbd0eff51","user":{"login":"N-buga","id":10629368,"avatar_url":"https://avatars.githubusercontent.com/u/10629368?v=3","gravatar_id":"","url":"https://api.github.com/users/N-buga","html_url":"https://github.com/N-buga","followers_url":"https://api.github.com/users/N-buga/followers","following_url":"https://api.github.com/users/N-buga/following{/other_user}","gists_url":"https://api.github.com/users/N-buga/gists{/gist_id}","starred_url":"https://api.github.com/users/N-buga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-buga/subscriptions","organizations_url":"https://api.github.com/users/N-buga/orgs","repos_url":"https://api.github.com/users/N-buga/repos","events_url":"https://api.github.com/users/N-buga/events{/privacy}","received_events_url":"https://api.github.com/users/N-buga/received_events","type":"User","site_admin":false},"repo":{"id":52168242,"name":"assignments-2","full_name":"N-buga/assignments-2","owner":{"login":"N-buga","id":10629368,"avatar_url":"https://avatars.githubusercontent.com/u/10629368?v=3","gravatar_id":"","url":"https://api.github.com/users/N-buga","html_url":"https://github.com/N-buga","followers_url":"https://api.github.com/users/N-buga/followers","following_url":"https://api.github.com/users/N-buga/following{/other_user}","gists_url":"https://api.github.com/users/N-buga/gists{/gist_id}","starred_url":"https://api.github.com/users/N-buga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N-buga/subscriptions","organizations_url":"https://api.github.com/users/N-buga/orgs","repos_url":"https://api.github.com/users/N-buga/repos","events_url":"https://api.github.com/users/N-buga/events{/privacy}","received_events_url":"https://api.github.com/users/N-buga/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/N-buga/assignments-2","description":"","fork":true,"url":"https://api.github.com/repos/N-buga/assignments-2","forks_url":"https://api.github.com/repos/N-buga/assignments-2/forks","keys_url":"https://api.github.com/repos/N-buga/assignments-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/N-buga/assignments-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/N-buga/assignments-2/teams","hooks_url":"https://api.github.com/repos/N-buga/assignments-2/hooks","issue_events_url":"https://api.github.com/repos/N-buga/assignments-2/issues/events{/number}","events_url":"https://api.github.com/repos/N-buga/assignments-2/events","assignees_url":"https://api.github.com/repos/N-buga/assignments-2/assignees{/user}","branches_url":"https://api.github.com/repos/N-buga/assignments-2/branches{/branch}","tags_url":"https://api.github.com/repos/N-buga/assignments-2/tags","blobs_url":"https://api.github.com/repos/N-buga/assignments-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/N-buga/assignments-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/N-buga/assignments-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/N-buga/assignments-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/N-buga/assignments-2/statuses/{sha}","languages_url":"https://api.github.com/repos/N-buga/assignments-2/languages","stargazers_url":"https://api.github.com/repos/N-buga/assignments-2/stargazers","contributors_url":"https://api.github.com/repos/N-buga/assignments-2/contributors","subscribers_url":"https://api.github.com/repos/N-buga/assignments-2/subscribers","subscription_url":"https://api.github.com/repos/N-buga/assignments-2/subscription","commits_url":"https://api.github.com/repos/N-buga/assignments-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/N-buga/assignments-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/N-buga/assignments-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/N-buga/assignments-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/N-buga/assignments-2/contents/{+path}","compare_url":"https://api.github.com/repos/N-buga/assignments-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/N-buga/assignments-2/merges","archive_url":"https://api.github.com/repos/N-buga/assignments-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/N-buga/assignments-2/downloads","issues_url":"https://api.github.com/repos/N-buga/assignments-2/issues{/number}","pulls_url":"https://api.github.com/repos/N-buga/assignments-2/pulls{/number}","milestones_url":"https://api.github.com/repos/N-buga/assignments-2/milestones{/number}","notifications_url":"https://api.github.com/repos/N-buga/assignments-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/N-buga/assignments-2/labels{/name}","releases_url":"https://api.github.com/repos/N-buga/assignments-2/releases{/id}","deployments_url":"https://api.github.com/repos/N-buga/assignments-2/deployments","created_at":"2016-02-20T18:21:22Z","updated_at":"2016-02-20T18:21:23Z","pushed_at":"2016-03-31T10:37:17Z","git_url":"git://github.com/N-buga/assignments-2.git","ssh_url":"git@github.com:N-buga/assignments-2.git","clone_url":"https://github.com/N-buga/assignments-2.git","svn_url":"https://github.com/N-buga/assignments-2","homepage":null,"size":41,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"java-course-au:master","ref":"master","sha":"a343da032205961726de4f3c67c9c43b3436ebb9","user":{"login":"java-course-au","id":14248092,"avatar_url":"https://avatars.githubusercontent.com/u/14248092?v=3","gravatar_id":"","url":"https://api.github.com/users/java-course-au","html_url":"https://github.com/java-course-au","followers_url":"https://api.github.com/users/java-course-au/followers","following_url":"https://api.github.com/users/java-course-au/following{/other_user}","gists_url":"https://api.github.com/users/java-course-au/gists{/gist_id}","starred_url":"https://api.github.com/users/java-course-au/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/java-course-au/subscriptions","organizations_url":"https://api.github.com/users/java-course-au/orgs","repos_url":"https://api.github.com/users/java-course-au/repos","events_url":"https://api.github.com/users/java-course-au/events{/privacy}","received_events_url":"https://api.github.com/users/java-course-au/received_events","type":"Organization","site_admin":false},"repo":{"id":51697606,"name":"assignments-2","full_name":"java-course-au/assignments-2","owner":{"login":"java-course-au","id":14248092,"avatar_url":"https://avatars.githubusercontent.com/u/14248092?v=3","gravatar_id":"","url":"https://api.github.com/users/java-course-au","html_url":"https://github.com/java-course-au","followers_url":"https://api.github.com/users/java-course-au/followers","following_url":"https://api.github.com/users/java-course-au/following{/other_user}","gists_url":"https://api.github.com/users/java-course-au/gists{/gist_id}","starred_url":"https://api.github.com/users/java-course-au/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/java-course-au/subscriptions","organizations_url":"https://api.github.com/users/java-course-au/orgs","repos_url":"https://api.github.com/users/java-course-au/repos","events_url":"https://api.github.com/users/java-course-au/events{/privacy}","received_events_url":"https://api.github.com/users/java-course-au/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/java-course-au/assignments-2","description":"","fork":false,"url":"https://api.github.com/repos/java-course-au/assignments-2","forks_url":"https://api.github.com/repos/java-course-au/assignments-2/forks","keys_url":"https://api.github.com/repos/java-course-au/assignments-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/java-course-au/assignments-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/java-course-au/assignments-2/teams","hooks_url":"https://api.github.com/repos/java-course-au/assignments-2/hooks","issue_events_url":"https://api.github.com/repos/java-course-au/assignments-2/issues/events{/number}","events_url":"https://api.github.com/repos/java-course-au/assignments-2/events","assignees_url":"https://api.github.com/repos/java-course-au/assignments-2/assignees{/user}","branches_url":"https://api.github.com/repos/java-course-au/assignments-2/branches{/branch}","tags_url":"https://api.github.com/repos/java-course-au/assignments-2/tags","blobs_url":"https://api.github.com/repos/java-course-au/assignments-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/java-course-au/assignments-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/java-course-au/assignments-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/java-course-au/assignments-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/java-course-au/assignments-2/statuses/{sha}","languages_url":"https://api.github.com/repos/java-course-au/assignments-2/languages","stargazers_url":"https://api.github.com/repos/java-course-au/assignments-2/stargazers","contributors_url":"https://api.github.com/repos/java-course-au/assignments-2/contributors","subscribers_url":"https://api.github.com/repos/java-course-au/assignments-2/subscribers","subscription_url":"https://api.github.com/repos/java-course-au/assignments-2/subscription","commits_url":"https://api.github.com/repos/java-course-au/assignments-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/java-course-au/assignments-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/java-course-au/assignments-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/java-course-au/assignments-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/java-course-au/assignments-2/contents/{+path}","compare_url":"https://api.github.com/repos/java-course-au/assignments-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/java-course-au/assignments-2/merges","archive_url":"https://api.github.com/repos/java-course-au/assignments-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/java-course-au/assignments-2/downloads","issues_url":"https://api.github.com/repos/java-course-au/assignments-2/issues{/number}","pulls_url":"https://api.github.com/repos/java-course-au/assignments-2/pulls{/number}","milestones_url":"https://api.github.com/repos/java-course-au/assignments-2/milestones{/number}","notifications_url":"https://api.github.com/repos/java-course-au/assignments-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/java-course-au/assignments-2/labels{/name}","releases_url":"https://api.github.com/repos/java-course-au/assignments-2/releases{/id}","deployments_url":"https://api.github.com/repos/java-course-au/assignments-2/deployments","created_at":"2016-02-14T14:22:46Z","updated_at":"2016-02-14T14:52:34Z","pushed_at":"2016-04-01T10:37:00Z","git_url":"git://github.com/java-course-au/assignments-2.git","ssh_url":"git@github.com:java-course-au/assignments-2.git","clone_url":"https://github.com/java-course-au/assignments-2.git","svn_url":"https://github.com/java-course-au/assignments-2","homepage":null,"size":479,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":5,"forks":15,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44"},"html":{"href":"https://github.com/java-course-au/assignments-2/pull/44"},"issue":{"href":"https://api.github.com/repos/java-course-au/assignments-2/issues/44"},"comments":{"href":"https://api.github.com/repos/java-course-au/assignments-2/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/java-course-au/assignments-2/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/java-course-au/assignments-2/statuses/4fcce2019000ba10a399561cb19e555cbd0eff51"}}}}