{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/76409618","id":76409618,"diff_hunk":"@@ -68,45 +70,45 @@ public String getMailetInfo() {\n \n     public void service(Mail mail) {\n         log(\"Logging mail \" + mail.getName());\n-        if (comment != null) log(comment);\n+        comment();\n         try {\n-            if (headers) log(getMessageHeaders(mail.getMessage()));\n-            if (body) {\n-                int len = bodyMax > 0 ? bodyMax : mail.getMessage().getSize();\n-                StringBuilder text = new StringBuilder(len);\n-                InputStream is = mail.getMessage().getRawInputStream();\n-                byte[] buf = new byte[1024];\n-                int read;\n-                while (text.length() < len && (read = is.read(buf)) > -1) {\n-                    text.append(new String(buf, 0, Math.min(read, len - text.length())));\n-                }\n-                log(text.toString());\n-            }\n-        }\n-        catch (MessagingException e) {\n+            MimeMessage message = mail.getMessage();\n+            headers(message);\n+            body(message);\n+        } catch (MessagingException e) {\n             log(\"Error logging message.\", e);\n-        }\n-        catch (java.io.IOException e) {\n+        } catch (java.io.IOException e) {\n             log(\"Error logging message.\", e);\n         }\n         if (!passThrough) {\n             mail.setState(Mail.GHOST);\n         }\n     }\n \n-    /**\n-     * Utility method for obtaining a string representation of a\n-     * Message's headers\n-     * \n-     * @param message\n-     */\n-    private String getMessageHeaders(MimeMessage message) throws MessagingException {\n-        @SuppressWarnings(\"unchecked\")\n-        Enumeration<String> heads = message.getAllHeaderLines();\n-        StringBuilder headBuffer = new StringBuilder(1024).append(\"\\n\");\n-        while(heads.hasMoreElements()) {\n-            headBuffer.append(heads.nextElement().toString()).append(\"\\n\");\n+    private void comment() {\n+        if (comment != null) {\n+            log(comment);\n+        }\n+    }\n+\n+    @SuppressWarnings(\"unchecked\")\n+    private void headers(MimeMessage message) throws MessagingException {\n+        if (headers) {\n+            log(\"\\n\");\n+            for (String header : Collections.list((Enumeration<String>) message.getAllHeaderLines())) {\n+                log(header + \"\\n\");","path":"mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java","position":118,"original_position":92,"commit_id":"6692bd5cfbf9c7010efc4f7ea7da31bdda2a4ba9","original_commit_id":"6692bd5cfbf9c7010efc4f7ea7da31bdda2a4ba9","user":{"login":"aduprat","id":2900528,"avatar_url":"https://avatars.githubusercontent.com/u/2900528?v=3","gravatar_id":"","url":"https://api.github.com/users/aduprat","html_url":"https://github.com/aduprat","followers_url":"https://api.github.com/users/aduprat/followers","following_url":"https://api.github.com/users/aduprat/following{/other_user}","gists_url":"https://api.github.com/users/aduprat/gists{/gist_id}","starred_url":"https://api.github.com/users/aduprat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduprat/subscriptions","organizations_url":"https://api.github.com/users/aduprat/orgs","repos_url":"https://api.github.com/users/aduprat/repos","events_url":"https://api.github.com/users/aduprat/events{/privacy}","received_events_url":"https://api.github.com/users/aduprat/received_events","type":"User","site_admin":false},"body":"The log method is from MailetContext, so i don't want to break it.","created_at":"2016-08-26T12:23:56Z","updated_at":"2016-08-26T12:23:56Z","html_url":"https://github.com/linagora/james-project/pull/372#discussion_r76409618","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/372","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/76409618"},"html":{"href":"https://github.com/linagora/james-project/pull/372#discussion_r76409618"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/372"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/372","id":82727894,"html_url":"https://github.com/linagora/james-project/pull/372","diff_url":"https://github.com/linagora/james-project/pull/372.diff","patch_url":"https://github.com/linagora/james-project/pull/372.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/372","number":372,"state":"open","locked":false,"title":"Mailet-99 Refactor LogMessage","user":{"login":"aduprat","id":2900528,"avatar_url":"https://avatars.githubusercontent.com/u/2900528?v=3","gravatar_id":"","url":"https://api.github.com/users/aduprat","html_url":"https://github.com/aduprat","followers_url":"https://api.github.com/users/aduprat/followers","following_url":"https://api.github.com/users/aduprat/following{/other_user}","gists_url":"https://api.github.com/users/aduprat/gists{/gist_id}","starred_url":"https://api.github.com/users/aduprat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduprat/subscriptions","organizations_url":"https://api.github.com/users/aduprat/orgs","repos_url":"https://api.github.com/users/aduprat/repos","events_url":"https://api.github.com/users/aduprat/events{/privacy}","received_events_url":"https://api.github.com/users/aduprat/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-25T14:16:46Z","updated_at":"2016-08-26T12:23:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92267d94c95f48fb35a204fa45bec6c733ad2a7e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/372/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/372/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/372/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/6692bd5cfbf9c7010efc4f7ea7da31bdda2a4ba9","head":{"label":"aduprat:MAILET-99","ref":"MAILET-99","sha":"6692bd5cfbf9c7010efc4f7ea7da31bdda2a4ba9","user":{"login":"aduprat","id":2900528,"avatar_url":"https://avatars.githubusercontent.com/u/2900528?v=3","gravatar_id":"","url":"https://api.github.com/users/aduprat","html_url":"https://github.com/aduprat","followers_url":"https://api.github.com/users/aduprat/followers","following_url":"https://api.github.com/users/aduprat/following{/other_user}","gists_url":"https://api.github.com/users/aduprat/gists{/gist_id}","starred_url":"https://api.github.com/users/aduprat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduprat/subscriptions","organizations_url":"https://api.github.com/users/aduprat/orgs","repos_url":"https://api.github.com/users/aduprat/repos","events_url":"https://api.github.com/users/aduprat/events{/privacy}","received_events_url":"https://api.github.com/users/aduprat/received_events","type":"User","site_admin":false},"repo":{"id":39448317,"name":"james-project","full_name":"aduprat/james-project","owner":{"login":"aduprat","id":2900528,"avatar_url":"https://avatars.githubusercontent.com/u/2900528?v=3","gravatar_id":"","url":"https://api.github.com/users/aduprat","html_url":"https://github.com/aduprat","followers_url":"https://api.github.com/users/aduprat/followers","following_url":"https://api.github.com/users/aduprat/following{/other_user}","gists_url":"https://api.github.com/users/aduprat/gists{/gist_id}","starred_url":"https://api.github.com/users/aduprat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduprat/subscriptions","organizations_url":"https://api.github.com/users/aduprat/orgs","repos_url":"https://api.github.com/users/aduprat/repos","events_url":"https://api.github.com/users/aduprat/events{/privacy}","received_events_url":"https://api.github.com/users/aduprat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aduprat/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/aduprat/james-project","forks_url":"https://api.github.com/repos/aduprat/james-project/forks","keys_url":"https://api.github.com/repos/aduprat/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aduprat/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aduprat/james-project/teams","hooks_url":"https://api.github.com/repos/aduprat/james-project/hooks","issue_events_url":"https://api.github.com/repos/aduprat/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/aduprat/james-project/events","assignees_url":"https://api.github.com/repos/aduprat/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/aduprat/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/aduprat/james-project/tags","blobs_url":"https://api.github.com/repos/aduprat/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aduprat/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aduprat/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/aduprat/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aduprat/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/aduprat/james-project/languages","stargazers_url":"https://api.github.com/repos/aduprat/james-project/stargazers","contributors_url":"https://api.github.com/repos/aduprat/james-project/contributors","subscribers_url":"https://api.github.com/repos/aduprat/james-project/subscribers","subscription_url":"https://api.github.com/repos/aduprat/james-project/subscription","commits_url":"https://api.github.com/repos/aduprat/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/aduprat/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/aduprat/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/aduprat/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/aduprat/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/aduprat/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aduprat/james-project/merges","archive_url":"https://api.github.com/repos/aduprat/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aduprat/james-project/downloads","issues_url":"https://api.github.com/repos/aduprat/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/aduprat/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/aduprat/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/aduprat/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aduprat/james-project/labels{/name}","releases_url":"https://api.github.com/repos/aduprat/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/aduprat/james-project/deployments","created_at":"2015-07-21T13:55:14Z","updated_at":"2016-01-13T10:07:40Z","pushed_at":"2016-08-26T06:46:21Z","git_url":"git://github.com/aduprat/james-project.git","ssh_url":"git@github.com:aduprat/james-project.git","clone_url":"https://github.com/aduprat/james-project.git","svn_url":"https://github.com/aduprat/james-project","homepage":null,"size":13903,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"e708298ac25b22c3253fcc2d8bfa14fe9e8c3ae4","user":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2016-07-01T17:37:20Z","pushed_at":"2016-08-26T08:11:08Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":15897,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":25,"forks":8,"open_issues":25,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/372"},"html":{"href":"https://github.com/linagora/james-project/pull/372"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/372"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/372/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/372/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/372/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/6692bd5cfbf9c7010efc4f7ea7da31bdda2a4ba9"}}}}
{"actor":{"display_login":"aduprat"}}