{"action":"created","comment":{"url":"https://api.github.com/repos/eXist-db/exist/pulls/comments/38125099","id":38125099,"diff_hunk":"@@ -21,89 +34,78 @@\n import org.exist.storage.txn.Txn;\n \n /**\n- *\n  * @author alex\n  */\n public class UpdateBinaryLoggable extends AbstractLoggable {\n \n-   protected final static Logger LOG = LogManager.getLogger(RenameBinaryLoggable.class);\n-   \n-   DBBroker broker;\n-   File original;\n-   File backup;\n-   /**\n-    * Creates a new instance of RenameBinaryLoggable\n-    */\n-   public UpdateBinaryLoggable(DBBroker broker,Txn txn,File original,File backup)\n-   {\n-      super(NativeBroker.LOG_UPDATE_BINARY,txn.getId());\n-      this.broker = broker;\n-      this.original = original;\n-      this.backup = backup;\n-   }\n-   \n-   public UpdateBinaryLoggable(DBBroker broker,long transactionId) {\n-      super(NativeBroker.LOG_UPDATE_BINARY,transactionId);\n-      this.broker = broker;\n-   }\n-   \n-   /* (non-Javadoc)\n-    * @see org.exist.storage.log.Loggable#write(java.nio.ByteBuffer)\n-    */\n-   public void write(ByteBuffer out) {\n-      final String originalPath = original.getAbsolutePath();\n-      byte [] data = originalPath.getBytes();\n-      out.putInt(data.length);\n-      out.put(data);\n-      final String backupPath = backup.getAbsolutePath();\n-      data = backupPath.getBytes();\n-      out.putInt(data.length);\n-      out.put(data);\n-    }\n+    private final static Logger LOG = LogManager.getLogger(UpdateBinaryLoggable.class);\n+\n+    private File original;\n+    private File backup;\n \n-    /* (non-Javadoc)\n-     * @see org.exist.storage.log.Loggable#read(java.nio.ByteBuffer)\n+    /**\n+     * Creates a new instance of RenameBinaryLoggable\n      */\n-    public void read(ByteBuffer in) {\n-       int size = in.getInt();\n-       byte [] data = new byte[size];\n-       in.get(data);\n-       original = new File(new String(data));\n-       size = in.getInt();\n-       data = new byte[size];\n-       in.get(data);\n-       backup = new File(new String(data));\n+    public UpdateBinaryLoggable(final DBBroker broker, final Txn txn, File original, final File backup) {\n+        super(NativeBroker.LOG_UPDATE_BINARY, txn.getId());\n+        this.original = original;\n+        this.backup = backup;\n     }\n \n-    /* (non-Javadoc)\n-     * @see org.exist.storage.log.Loggable#getLogSize()\n-     */\n+    public UpdateBinaryLoggable(final DBBroker broker, final long transactionId) {\n+        super(NativeBroker.LOG_UPDATE_BINARY, transactionId);\n+    }\n+\n+    @Override\n+    public void write(final ByteBuffer out) {\n+        final String originalPath = original.getAbsolutePath();\n+        byte[] data = originalPath.getBytes(StandardCharsets.UTF_8);\n+        out.putInt(data.length);\n+        out.put(data);\n+        final String backupPath = backup.getAbsolutePath();\n+        data = backupPath.getBytes(StandardCharsets.UTF_8);\n+        out.putInt(data.length);\n+        out.put(data);\n+    }\n+\n+    @Override\n+    public void read(final ByteBuffer in) {\n+        int size = in.getInt();\n+        byte[] data = new byte[size];\n+        in.get(data);\n+        original = new File(new String(data, StandardCharsets.UTF_8));\n+        size = in.getInt();\n+        data = new byte[size];\n+        in.get(data);\n+        backup = new File(new String(data, StandardCharsets.UTF_8));\n+    }\n+\n+    @Override\n     public int getLogSize() {\n-        return 8 + original.getAbsolutePath().getBytes().length + backup.getAbsolutePath().getBytes().length;\n+        return 8 + original.getAbsolutePath().getBytes(StandardCharsets.UTF_8).length + backup.getAbsolutePath().getBytes(StandardCharsets.UTF_8).length;\n     }\n \n+    @Override\n     public void redo() throws LogException {\n-       // TODO: is there something to do?  The file has been written\n+        // TODO: is there something to do?  The file has been written\n     }\n-    \n+\n+    @Override\n     public void undo() throws LogException {\n-       try {\n-          final FileInputStream is = new FileInputStream(backup);\n-          final FileOutputStream os = new FileOutputStream(original);\n-          final byte [] buffer = new byte[4096];\n-          int len;\n-          while ((len=is.read(buffer))>=0) {\n-             os.write(buffer,0,len);\n-          }\n-          os.close();\n-          is.close();\n-       } catch (final IOException ex) {\n-          \n-       }\n-    }\n-    \n-     public String dump() {\n-        return super.dump() + \" - update \"+original+\" to \"+backup;\n+        try(final FileInputStream is = new FileInputStream(backup);\n+                final FileOutputStream os = new FileOutputStream(original)) {\n+            final byte[] buffer = new byte[4096];\n+            int len = -1;\n+            while ((len = is.read(buffer)) > -1) {","path":"src/org/exist/storage/UpdateBinaryLoggable.java","position":173,"original_position":173,"commit_id":"e3ed187c6e1a5db2bf73e5f999f5e29c32fc8970","original_commit_id":"e3ed187c6e1a5db2bf73e5f999f5e29c32fc8970","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"body":"Yes this can be done using `Files.copy`... In-fact this probably is done in https://github.com/eXist-db/exist/pull/768 ;-)","created_at":"2015-08-27T17:53:45Z","updated_at":"2015-08-27T17:53:45Z","html_url":"https://github.com/eXist-db/exist/pull/767#discussion_r38125099","pull_request_url":"https://api.github.com/repos/eXist-db/exist/pulls/767","_links":{"self":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/comments/38125099"},"html":{"href":"https://github.com/eXist-db/exist/pull/767#discussion_r38125099"},"pull_request":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/767"}}},"pull_request":{"url":"https://api.github.com/repos/eXist-db/exist/pulls/767","id":43532166,"html_url":"https://github.com/eXist-db/exist/pull/767","diff_url":"https://github.com/eXist-db/exist/pull/767.diff","patch_url":"https://github.com/eXist-db/exist/pull/767.patch","issue_url":"https://api.github.com/repos/eXist-db/exist/issues/767","number":767,"state":"open","locked":false,"title":"Removes the need of reflection for Loggables","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"body":"Java 8 provide method references; As the Enumeration of Loggable sub-classes is statically known and their constructors fixed, we can instead use a method reference to the constructor of each Loggable to avoid the expensive use of reflection at runtime.","created_at":"2015-08-27T15:37:13Z","updated_at":"2015-08-27T17:53:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b5c573163bf1278aa9020e01ca0d79f3caf685e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eXist-db/exist/pulls/767/commits","review_comments_url":"https://api.github.com/repos/eXist-db/exist/pulls/767/comments","review_comment_url":"https://api.github.com/repos/eXist-db/exist/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eXist-db/exist/issues/767/comments","statuses_url":"https://api.github.com/repos/eXist-db/exist/statuses/e3ed187c6e1a5db2bf73e5f999f5e29c32fc8970","head":{"label":"adamretter:feature/non-reflect-loggables","ref":"feature/non-reflect-loggables","sha":"e3ed187c6e1a5db2bf73e5f999f5e29c32fc8970","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"repo":{"id":11710746,"name":"exist","full_name":"adamretter/exist","owner":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adamretter/exist","description":"eXist Native XML Database","fork":true,"url":"https://api.github.com/repos/adamretter/exist","forks_url":"https://api.github.com/repos/adamretter/exist/forks","keys_url":"https://api.github.com/repos/adamretter/exist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adamretter/exist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adamretter/exist/teams","hooks_url":"https://api.github.com/repos/adamretter/exist/hooks","issue_events_url":"https://api.github.com/repos/adamretter/exist/issues/events{/number}","events_url":"https://api.github.com/repos/adamretter/exist/events","assignees_url":"https://api.github.com/repos/adamretter/exist/assignees{/user}","branches_url":"https://api.github.com/repos/adamretter/exist/branches{/branch}","tags_url":"https://api.github.com/repos/adamretter/exist/tags","blobs_url":"https://api.github.com/repos/adamretter/exist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adamretter/exist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adamretter/exist/git/refs{/sha}","trees_url":"https://api.github.com/repos/adamretter/exist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adamretter/exist/statuses/{sha}","languages_url":"https://api.github.com/repos/adamretter/exist/languages","stargazers_url":"https://api.github.com/repos/adamretter/exist/stargazers","contributors_url":"https://api.github.com/repos/adamretter/exist/contributors","subscribers_url":"https://api.github.com/repos/adamretter/exist/subscribers","subscription_url":"https://api.github.com/repos/adamretter/exist/subscription","commits_url":"https://api.github.com/repos/adamretter/exist/commits{/sha}","git_commits_url":"https://api.github.com/repos/adamretter/exist/git/commits{/sha}","comments_url":"https://api.github.com/repos/adamretter/exist/comments{/number}","issue_comment_url":"https://api.github.com/repos/adamretter/exist/issues/comments{/number}","contents_url":"https://api.github.com/repos/adamretter/exist/contents/{+path}","compare_url":"https://api.github.com/repos/adamretter/exist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adamretter/exist/merges","archive_url":"https://api.github.com/repos/adamretter/exist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adamretter/exist/downloads","issues_url":"https://api.github.com/repos/adamretter/exist/issues{/number}","pulls_url":"https://api.github.com/repos/adamretter/exist/pulls{/number}","milestones_url":"https://api.github.com/repos/adamretter/exist/milestones{/number}","notifications_url":"https://api.github.com/repos/adamretter/exist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adamretter/exist/labels{/name}","releases_url":"https://api.github.com/repos/adamretter/exist/releases{/id}","created_at":"2013-07-27T20:42:43Z","updated_at":"2015-05-04T19:36:39Z","pushed_at":"2015-08-27T17:08:15Z","git_url":"git://github.com/adamretter/exist.git","ssh_url":"git@github.com:adamretter/exist.git","clone_url":"https://github.com/adamretter/exist.git","svn_url":"https://github.com/adamretter/exist","homepage":null,"size":397518,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"develop"}},"base":{"label":"eXist-db:develop","ref":"develop","sha":"247fd809b22776129f09f9048c6186d7643da477","user":{"login":"eXist-db","id":2393489,"avatar_url":"https://avatars.githubusercontent.com/u/2393489?v=3","gravatar_id":"","url":"https://api.github.com/users/eXist-db","html_url":"https://github.com/eXist-db","followers_url":"https://api.github.com/users/eXist-db/followers","following_url":"https://api.github.com/users/eXist-db/following{/other_user}","gists_url":"https://api.github.com/users/eXist-db/gists{/gist_id}","starred_url":"https://api.github.com/users/eXist-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eXist-db/subscriptions","organizations_url":"https://api.github.com/users/eXist-db/orgs","repos_url":"https://api.github.com/users/eXist-db/repos","events_url":"https://api.github.com/users/eXist-db/events{/privacy}","received_events_url":"https://api.github.com/users/eXist-db/received_events","type":"Organization","site_admin":false},"repo":{"id":11695619,"name":"exist","full_name":"eXist-db/exist","owner":{"login":"eXist-db","id":2393489,"avatar_url":"https://avatars.githubusercontent.com/u/2393489?v=3","gravatar_id":"","url":"https://api.github.com/users/eXist-db","html_url":"https://github.com/eXist-db","followers_url":"https://api.github.com/users/eXist-db/followers","following_url":"https://api.github.com/users/eXist-db/following{/other_user}","gists_url":"https://api.github.com/users/eXist-db/gists{/gist_id}","starred_url":"https://api.github.com/users/eXist-db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eXist-db/subscriptions","organizations_url":"https://api.github.com/users/eXist-db/orgs","repos_url":"https://api.github.com/users/eXist-db/repos","events_url":"https://api.github.com/users/eXist-db/events{/privacy}","received_events_url":"https://api.github.com/users/eXist-db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eXist-db/exist","description":"eXist Native XML Database and Application Platform","fork":false,"url":"https://api.github.com/repos/eXist-db/exist","forks_url":"https://api.github.com/repos/eXist-db/exist/forks","keys_url":"https://api.github.com/repos/eXist-db/exist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eXist-db/exist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eXist-db/exist/teams","hooks_url":"https://api.github.com/repos/eXist-db/exist/hooks","issue_events_url":"https://api.github.com/repos/eXist-db/exist/issues/events{/number}","events_url":"https://api.github.com/repos/eXist-db/exist/events","assignees_url":"https://api.github.com/repos/eXist-db/exist/assignees{/user}","branches_url":"https://api.github.com/repos/eXist-db/exist/branches{/branch}","tags_url":"https://api.github.com/repos/eXist-db/exist/tags","blobs_url":"https://api.github.com/repos/eXist-db/exist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eXist-db/exist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eXist-db/exist/git/refs{/sha}","trees_url":"https://api.github.com/repos/eXist-db/exist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eXist-db/exist/statuses/{sha}","languages_url":"https://api.github.com/repos/eXist-db/exist/languages","stargazers_url":"https://api.github.com/repos/eXist-db/exist/stargazers","contributors_url":"https://api.github.com/repos/eXist-db/exist/contributors","subscribers_url":"https://api.github.com/repos/eXist-db/exist/subscribers","subscription_url":"https://api.github.com/repos/eXist-db/exist/subscription","commits_url":"https://api.github.com/repos/eXist-db/exist/commits{/sha}","git_commits_url":"https://api.github.com/repos/eXist-db/exist/git/commits{/sha}","comments_url":"https://api.github.com/repos/eXist-db/exist/comments{/number}","issue_comment_url":"https://api.github.com/repos/eXist-db/exist/issues/comments{/number}","contents_url":"https://api.github.com/repos/eXist-db/exist/contents/{+path}","compare_url":"https://api.github.com/repos/eXist-db/exist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eXist-db/exist/merges","archive_url":"https://api.github.com/repos/eXist-db/exist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eXist-db/exist/downloads","issues_url":"https://api.github.com/repos/eXist-db/exist/issues{/number}","pulls_url":"https://api.github.com/repos/eXist-db/exist/pulls{/number}","milestones_url":"https://api.github.com/repos/eXist-db/exist/milestones{/number}","notifications_url":"https://api.github.com/repos/eXist-db/exist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eXist-db/exist/labels{/name}","releases_url":"https://api.github.com/repos/eXist-db/exist/releases{/id}","created_at":"2013-07-26T21:53:48Z","updated_at":"2015-08-25T02:41:13Z","pushed_at":"2015-08-27T17:11:27Z","git_url":"git://github.com/eXist-db/exist.git","ssh_url":"git@github.com:eXist-db/exist.git","clone_url":"https://github.com/eXist-db/exist.git","svn_url":"https://github.com/eXist-db/exist","homepage":"http://www.exist-db.org","size":436052,"stargazers_count":92,"watchers_count":92,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":127,"forks":68,"open_issues":127,"watchers":92,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/767"},"html":{"href":"https://github.com/eXist-db/exist/pull/767"},"issue":{"href":"https://api.github.com/repos/eXist-db/exist/issues/767"},"comments":{"href":"https://api.github.com/repos/eXist-db/exist/issues/767/comments"},"review_comments":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/767/comments"},"review_comment":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eXist-db/exist/pulls/767/commits"},"statuses":{"href":"https://api.github.com/repos/eXist-db/exist/statuses/e3ed187c6e1a5db2bf73e5f999f5e29c32fc8970"}}}}