{"action":"created","comment":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/41735881","id":41735881,"diff_hunk":"@@ -0,0 +1,104 @@\n+/*\n+ * Copyright (c) 2002-2015 \"Neo Technology,\"\n+ * Network Engine for Objects in Lund AB [http://neotechnology.com]\n+ *\n+ * This file is part of Neo4j.\n+ *\n+ * Neo4j is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+package org.neo4j.kernel.impl.util;\n+\n+import java.io.Closeable;\n+import java.io.IOException;\n+\n+import static org.neo4j.helpers.Exceptions.launderedException;\n+\n+/**\n+ * Closes multiple {@link Closeable} instances. Ensures to call {@link Closeable#close()} on all\n+ * instances, even if one or more throws {@link IOException} or any other unchecked exception,\n+ * before throwing the first exception (or the first IOException, if any, as the parent exception),\n+ * with additional exceptions as suppressed.\n+ */\n+public class MultiCloseable implements Closeable\n+{\n+    private final Closeable[] closeables;\n+\n+    public MultiCloseable( Closeable... closeables )\n+    {\n+        this.closeables = closeables;\n+    }\n+\n+    @Override\n+    public void close() throws IOException\n+    {\n+        Throwable exception = null;\n+        for ( Closeable closeable : closeables )\n+        {\n+            try\n+            {\n+                closeable.close();\n+            }\n+            catch ( IOException e )\n+            {\n+                if ( exception == null )\n+                {\n+                    exception = e;\n+                }\n+                else\n+                {\n+                    if ( !( exception instanceof IOException) )\n+                    {\n+                        // We end up here if a previous Closeable threw a non-IOException, such that\n+                        // the exception variable now points to that exception. In the end, if there are\n+                        // only non-IOExceptions thrown it doesn't make sense to convert those into an\n+                        // IOException, since it may have unexpected results from the caller POV.\n+                        // Therefore we convert the exception variable to an IOException, flipping\n+                        // this exception from being suppressed by the existing exception, to being the\n+                        // top level exception with the existing one, including all its suppressed,\n+                        // as suppressed exceptions of this IOException\n+                        Throwable existing = exception;\n+                        exception = e;\n+\n+                        // Unfortunately we cannot flatten out the suppressed hierarchy here so it'll have to be:\n+                        // exception: IOException\n+                        //   |\n+                        //   |-- existing: Throwable\n+                        //         |\n+                        //         |-- suppressed...: Throwable\n+                        exception.addSuppressed( existing );\n+                    }\n+                    else\n+                    {\n+                        exception.addSuppressed( e );\n+                    }\n+                }\n+            }\n+            catch ( Throwable t )\n+            {\n+                if ( exception == null )\n+                {\n+                    exception = t;\n+                }\n+                else\n+                {\n+                    exception.addSuppressed( t );\n+                }\n+            }\n+        }\n+        if ( exception != null )\n+        {\n+            throw launderedException( IOException.class, exception );\n+        }\n+    }","path":"community/kernel/src/main/java/org/neo4j/kernel/impl/util/MultiCloseable.java","position":103,"original_position":103,"commit_id":"61b5e659f3023c7b0e969b30bd6c82d5153bc065","original_commit_id":"61b5e659f3023c7b0e969b30bd6c82d5153bc065","user":{"login":"davidegrohmann","id":6573166,"avatar_url":"https://avatars.githubusercontent.com/u/6573166?v=3","gravatar_id":"","url":"https://api.github.com/users/davidegrohmann","html_url":"https://github.com/davidegrohmann","followers_url":"https://api.github.com/users/davidegrohmann/followers","following_url":"https://api.github.com/users/davidegrohmann/following{/other_user}","gists_url":"https://api.github.com/users/davidegrohmann/gists{/gist_id}","starred_url":"https://api.github.com/users/davidegrohmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidegrohmann/subscriptions","organizations_url":"https://api.github.com/users/davidegrohmann/orgs","repos_url":"https://api.github.com/users/davidegrohmann/repos","events_url":"https://api.github.com/users/davidegrohmann/events{/privacy}","received_events_url":"https://api.github.com/users/davidegrohmann/received_events","type":"User","site_admin":false},"body":"Why not using `LifeCycle` for this? I don't see the point of adding so much extra complexity since we have already code that does something like this.","created_at":"2015-10-12T08:58:39Z","updated_at":"2015-10-12T08:58:39Z","html_url":"https://github.com/neo4j/neo4j/pull/5599#discussion_r41735881","pull_request_url":"https://api.github.com/repos/neo4j/neo4j/pulls/5599","_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments/41735881"},"html":{"href":"https://github.com/neo4j/neo4j/pull/5599#discussion_r41735881"},"pull_request":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/5599"}}},"pull_request":{"url":"https://api.github.com/repos/neo4j/neo4j/pulls/5599","id":47367098,"html_url":"https://github.com/neo4j/neo4j/pull/5599","diff_url":"https://github.com/neo4j/neo4j/pull/5599.diff","patch_url":"https://github.com/neo4j/neo4j/pull/5599.patch","issue_url":"https://api.github.com/repos/neo4j/neo4j/issues/5599","number":5599,"state":"open","locked":false,"title":"Introduces asynchronous logging","user":{"login":"tinwelint","id":187292,"avatar_url":"https://avatars.githubusercontent.com/u/187292?v=3","gravatar_id":"","url":"https://api.github.com/users/tinwelint","html_url":"https://github.com/tinwelint","followers_url":"https://api.github.com/users/tinwelint/followers","following_url":"https://api.github.com/users/tinwelint/following{/other_user}","gists_url":"https://api.github.com/users/tinwelint/gists{/gist_id}","starred_url":"https://api.github.com/users/tinwelint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinwelint/subscriptions","organizations_url":"https://api.github.com/users/tinwelint/orgs","repos_url":"https://api.github.com/users/tinwelint/repos","events_url":"https://api.github.com/users/tinwelint/events{/privacy}","received_events_url":"https://api.github.com/users/tinwelint/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-11T13:40:31Z","updated_at":"2015-10-12T08:58:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8919210b6ada10514bb537695841bea39d35bcc5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neo4j/neo4j/pulls/5599/commits","review_comments_url":"https://api.github.com/repos/neo4j/neo4j/pulls/5599/comments","review_comment_url":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neo4j/neo4j/issues/5599/comments","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/61b5e659f3023c7b0e969b30bd6c82d5153bc065","head":{"label":"tinwelint:2.3-async-log","ref":"2.3-async-log","sha":"61b5e659f3023c7b0e969b30bd6c82d5153bc065","user":{"login":"tinwelint","id":187292,"avatar_url":"https://avatars.githubusercontent.com/u/187292?v=3","gravatar_id":"","url":"https://api.github.com/users/tinwelint","html_url":"https://github.com/tinwelint","followers_url":"https://api.github.com/users/tinwelint/followers","following_url":"https://api.github.com/users/tinwelint/following{/other_user}","gists_url":"https://api.github.com/users/tinwelint/gists{/gist_id}","starred_url":"https://api.github.com/users/tinwelint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinwelint/subscriptions","organizations_url":"https://api.github.com/users/tinwelint/orgs","repos_url":"https://api.github.com/users/tinwelint/repos","events_url":"https://api.github.com/users/tinwelint/events{/privacy}","received_events_url":"https://api.github.com/users/tinwelint/received_events","type":"User","site_admin":false},"repo":{"id":6666980,"name":"neo4j","full_name":"tinwelint/neo4j","owner":{"login":"tinwelint","id":187292,"avatar_url":"https://avatars.githubusercontent.com/u/187292?v=3","gravatar_id":"","url":"https://api.github.com/users/tinwelint","html_url":"https://github.com/tinwelint","followers_url":"https://api.github.com/users/tinwelint/followers","following_url":"https://api.github.com/users/tinwelint/following{/other_user}","gists_url":"https://api.github.com/users/tinwelint/gists{/gist_id}","starred_url":"https://api.github.com/users/tinwelint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinwelint/subscriptions","organizations_url":"https://api.github.com/users/tinwelint/orgs","repos_url":"https://api.github.com/users/tinwelint/repos","events_url":"https://api.github.com/users/tinwelint/events{/privacy}","received_events_url":"https://api.github.com/users/tinwelint/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tinwelint/neo4j","description":"","fork":true,"url":"https://api.github.com/repos/tinwelint/neo4j","forks_url":"https://api.github.com/repos/tinwelint/neo4j/forks","keys_url":"https://api.github.com/repos/tinwelint/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tinwelint/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tinwelint/neo4j/teams","hooks_url":"https://api.github.com/repos/tinwelint/neo4j/hooks","issue_events_url":"https://api.github.com/repos/tinwelint/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/tinwelint/neo4j/events","assignees_url":"https://api.github.com/repos/tinwelint/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/tinwelint/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/tinwelint/neo4j/tags","blobs_url":"https://api.github.com/repos/tinwelint/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tinwelint/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tinwelint/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/tinwelint/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tinwelint/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/tinwelint/neo4j/languages","stargazers_url":"https://api.github.com/repos/tinwelint/neo4j/stargazers","contributors_url":"https://api.github.com/repos/tinwelint/neo4j/contributors","subscribers_url":"https://api.github.com/repos/tinwelint/neo4j/subscribers","subscription_url":"https://api.github.com/repos/tinwelint/neo4j/subscription","commits_url":"https://api.github.com/repos/tinwelint/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/tinwelint/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/tinwelint/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/tinwelint/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/tinwelint/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/tinwelint/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tinwelint/neo4j/merges","archive_url":"https://api.github.com/repos/tinwelint/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tinwelint/neo4j/downloads","issues_url":"https://api.github.com/repos/tinwelint/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/tinwelint/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/tinwelint/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/tinwelint/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tinwelint/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/tinwelint/neo4j/releases{/id}","created_at":"2012-11-13T07:24:49Z","updated_at":"2014-12-16T07:20:14Z","pushed_at":"2015-10-12T08:46:37Z","git_url":"git://github.com/tinwelint/neo4j.git","ssh_url":"git@github.com:tinwelint/neo4j.git","clone_url":"https://github.com/tinwelint/neo4j.git","svn_url":"https://github.com/tinwelint/neo4j","homepage":null,"size":211949,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"neo4j:2.3","ref":"2.3","sha":"1db840c1bdbb66e887d31030a97421aead15ecf6","user":{"login":"neo4j","id":201120,"avatar_url":"https://avatars.githubusercontent.com/u/201120?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"repo":{"id":6650539,"name":"neo4j","full_name":"neo4j/neo4j","owner":{"login":"neo4j","id":201120,"avatar_url":"https://avatars.githubusercontent.com/u/201120?v=3","gravatar_id":"","url":"https://api.github.com/users/neo4j","html_url":"https://github.com/neo4j","followers_url":"https://api.github.com/users/neo4j/followers","following_url":"https://api.github.com/users/neo4j/following{/other_user}","gists_url":"https://api.github.com/users/neo4j/gists{/gist_id}","starred_url":"https://api.github.com/users/neo4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo4j/subscriptions","organizations_url":"https://api.github.com/users/neo4j/orgs","repos_url":"https://api.github.com/users/neo4j/repos","events_url":"https://api.github.com/users/neo4j/events{/privacy}","received_events_url":"https://api.github.com/users/neo4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neo4j/neo4j","description":"Graphs for Everyone","fork":false,"url":"https://api.github.com/repos/neo4j/neo4j","forks_url":"https://api.github.com/repos/neo4j/neo4j/forks","keys_url":"https://api.github.com/repos/neo4j/neo4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neo4j/neo4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neo4j/neo4j/teams","hooks_url":"https://api.github.com/repos/neo4j/neo4j/hooks","issue_events_url":"https://api.github.com/repos/neo4j/neo4j/issues/events{/number}","events_url":"https://api.github.com/repos/neo4j/neo4j/events","assignees_url":"https://api.github.com/repos/neo4j/neo4j/assignees{/user}","branches_url":"https://api.github.com/repos/neo4j/neo4j/branches{/branch}","tags_url":"https://api.github.com/repos/neo4j/neo4j/tags","blobs_url":"https://api.github.com/repos/neo4j/neo4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neo4j/neo4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neo4j/neo4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/neo4j/neo4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neo4j/neo4j/statuses/{sha}","languages_url":"https://api.github.com/repos/neo4j/neo4j/languages","stargazers_url":"https://api.github.com/repos/neo4j/neo4j/stargazers","contributors_url":"https://api.github.com/repos/neo4j/neo4j/contributors","subscribers_url":"https://api.github.com/repos/neo4j/neo4j/subscribers","subscription_url":"https://api.github.com/repos/neo4j/neo4j/subscription","commits_url":"https://api.github.com/repos/neo4j/neo4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/neo4j/neo4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/neo4j/neo4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/neo4j/neo4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/neo4j/neo4j/contents/{+path}","compare_url":"https://api.github.com/repos/neo4j/neo4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neo4j/neo4j/merges","archive_url":"https://api.github.com/repos/neo4j/neo4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neo4j/neo4j/downloads","issues_url":"https://api.github.com/repos/neo4j/neo4j/issues{/number}","pulls_url":"https://api.github.com/repos/neo4j/neo4j/pulls{/number}","milestones_url":"https://api.github.com/repos/neo4j/neo4j/milestones{/number}","notifications_url":"https://api.github.com/repos/neo4j/neo4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neo4j/neo4j/labels{/name}","releases_url":"https://api.github.com/repos/neo4j/neo4j/releases{/id}","created_at":"2012-11-12T08:46:15Z","updated_at":"2015-10-12T05:51:42Z","pushed_at":"2015-10-12T08:47:00Z","git_url":"git://github.com/neo4j/neo4j.git","ssh_url":"git@github.com:neo4j/neo4j.git","clone_url":"https://github.com/neo4j/neo4j.git","svn_url":"https://github.com/neo4j/neo4j","homepage":"http://neo4j.com","size":522051,"stargazers_count":2017,"watchers_count":2017,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":763,"mirror_url":null,"open_issues_count":497,"forks":763,"open_issues":497,"watchers":2017,"default_branch":"2.3"}},"_links":{"self":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/5599"},"html":{"href":"https://github.com/neo4j/neo4j/pull/5599"},"issue":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/5599"},"comments":{"href":"https://api.github.com/repos/neo4j/neo4j/issues/5599/comments"},"review_comments":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/5599/comments"},"review_comment":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neo4j/neo4j/pulls/5599/commits"},"statuses":{"href":"https://api.github.com/repos/neo4j/neo4j/statuses/61b5e659f3023c7b0e969b30bd6c82d5153bc065"}}}}