GitHub PullRequestReviewCommentEvent at 2014-08-06 15:05:37
Repository: infinispan
Actor: tristantarrant
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/infinispan/infinispan/pulls/comments/15879737","id":15879737,"diff_hunk":"@@ -0,0 +1,112 @@\n+package org.infinispan.server.websocket.json;\n+\n+import org.codehaus.jackson.map.ObjectMapper;\n+\n+import java.io.IOException;\n+import java.util.Collection;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.Set;\n+\n+/**\n+ * Json Object implementation. This is the only link between POJOs and particular JSON library implementation.\n+ *\n+ * @author slaskawiec\n+ */\n+public class JsonObject implements Map<String, Object> {\n+\n+   private static final ObjectMapper objectMapper = new ObjectMapper();\n+\n+   private Map<String, Object> internalStructure = new HashMap<String, Object>();\n+\n+   public static JsonObject fromString(String json) throws JsonConversionException {\n+      try {\n+         Map<String, Object> m = objectMapper.readValue(json, Map.class);\n+         JsonObject jsonObject = new JsonObject();\n+         jsonObject.putAll(m);","path":"server/websocket/src/main/java/org/infinispan/server/websocket/json/JsonObject.java","position":26,"original_position":26,"commit_id":"3609e0cd46112bfe64baa059cfee900d11bbef2d","original_commit_id":"3609e0cd46112bfe64baa059cfee900d11bbef2d","user":{"login":"tristantarrant","id":392478,"avatar_url":"https://avatars.githubusercontent.com/u/392478?v=2","gravatar_id":"a0bbac2ddda65366d24691b7d3daa735","url":"https://api.github.com/users/tristantarrant","html_url":"https://github.com/tristantarrant","followers_url":"https://api.github.com/users/tristantarrant/followers","following_url":"https://api.github.com/users/tristantarrant/following{/other_user}","gists_url":"https://api.github.com/users/tristantarrant/gists{/gist_id}","starred_url":"https://api.github.com/users/tristantarrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tristantarrant/subscriptions","organizations_url":"https://api.github.com/users/tristantarrant/orgs","repos_url":"https://api.github.com/users/tristantarrant/repos","events_url":"https://api.github.com/users/tristantarrant/events{/privacy}","received_events_url":"https://api.github.com/users/tristantarrant/received_events","type":"User","site_admin":false},"body":"I would have a private JsonObject constructor which takes the Map as a parameter, and assign that to the internalStructure. That way you avoid copying and a useless object","created_at":"2014-08-06T15:05:37Z","updated_at":"2014-08-06T15:05:37Z","html_url":"https://github.com/infinispan/infinispan/pull/2773#discussion_r15879737","pull_request_url":"https://api.github.com/repos/infinispan/infinispan/pulls/2773","_links":{"self":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/comments/15879737"},"html":{"href":"https://github.com/infinispan/infinispan/pull/2773#discussion_r15879737"},"pull_request":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/2773"}}},"pull_request":{"url":"https://api.github.com/repos/infinispan/infinispan/pulls/2773","id":19339978,"html_url":"https://github.com/infinispan/infinispan/pull/2773","diff_url":"https://github.com/infinispan/infinispan/pull/2773.diff","patch_url":"https://github.com/infinispan/infinispan/pull/2773.patch","issue_url":"https://api.github.com/repos/infinispan/infinispan/issues/2773","number":2773,"state":"open","title":"ISPN-3340 Switching from Json.org to Jackson","user":{"login":"altanis","id":541344,"avatar_url":"https://avatars.githubusercontent.com/u/541344?v=2","gravatar_id":"61cc983210024f203f746bbd1b70bd1c","url":"https://api.github.com/users/altanis","html_url":"https://github.com/altanis","followers_url":"https://api.github.com/users/altanis/followers","following_url":"https://api.github.com/users/altanis/following{/other_user}","gists_url":"https://api.github.com/users/altanis/gists{/gist_id}","starred_url":"https://api.github.com/users/altanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/altanis/subscriptions","organizations_url":"https://api.github.com/users/altanis/orgs","repos_url":"https://api.github.com/users/altanis/repos","events_url":"https://api.github.com/users/altanis/events{/privacy}","received_events_url":"https://api.github.com/users/altanis/received_events","type":"User","site_admin":false},"body":"Hi\r\n\r\nPlease take a look at proposed solution for https://issues.jboss.org/browse/ISPN-3340.\r\n\r\nThe main idea is to create JsonObject which is the only part connected to particular JSON implementation (in this case Jackson). This way switching to another implementation would not require any other changes. \r\n\r\nAdditionally I changed Exception policy a bit. All methods which write JSON from objects/maps should not throw any Exceptions. There is only one case where such thing occurs - when there is no fields for serialization. In this case we throw an Exception (there is even test for it). \r\nOn the other hand when we create JsonObject from String - parsing exceptions might happen and these are reported as JsonConversionException. The same might happen if we try to create JSON from simple type (String, Number etc). \r\n\r\nBest regards\r\nSebastian","created_at":"2014-08-05T12:59:05Z","updated_at":"2014-08-06T15:05:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7047618e8cdae2e4df36915f2523ed0ce4888e06","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/infinispan/infinispan/pulls/2773/commits","review_comments_url":"https://api.github.com/repos/infinispan/infinispan/pulls/2773/comments","review_comment_url":"https://api.github.com/repos/infinispan/infinispan/pulls/comments/{number}","comments_url":"https://api.github.com/repos/infinispan/infinispan/issues/2773/comments","statuses_url":"https://api.github.com/repos/infinispan/infinispan/statuses/3609e0cd46112bfe64baa059cfee900d11bbef2d","head":{"label":"altanis:ISPN-3340","ref":"ISPN-3340","sha":"3609e0cd46112bfe64baa059cfee900d11bbef2d","user":{"login":"altanis","id":541344,"avatar_url":"https://avatars.githubusercontent.com/u/541344?v=2","gravatar_id":"61cc983210024f203f746bbd1b70bd1c","url":"https://api.github.com/users/altanis","html_url":"https://github.com/altanis","followers_url":"https://api.github.com/users/altanis/followers","following_url":"https://api.github.com/users/altanis/following{/other_user}","gists_url":"https://api.github.com/users/altanis/gists{/gist_id}","starred_url":"https://api.github.com/users/altanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/altanis/subscriptions","organizations_url":"https://api.github.com/users/altanis/orgs","repos_url":"https://api.github.com/users/altanis/repos","events_url":"https://api.github.com/users/altanis/events{/privacy}","received_events_url":"https://api.github.com/users/altanis/received_events","type":"User","site_admin":false},"repo":{"id":22502379,"name":"infinispan","full_name":"altanis/infinispan","owner":{"login":"altanis","id":541344,"avatar_url":"https://avatars.githubusercontent.com/u/541344?v=2","gravatar_id":"61cc983210024f203f746bbd1b70bd1c","url":"https://api.github.com/users/altanis","html_url":"https://github.com/altanis","followers_url":"https://api.github.com/users/altanis/followers","following_url":"https://api.github.com/users/altanis/following{/other_user}","gists_url":"https://api.github.com/users/altanis/gists{/gist_id}","starred_url":"https://api.github.com/users/altanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/altanis/subscriptions","organizations_url":"https://api.github.com/users/altanis/orgs","repos_url":"https://api.github.com/users/altanis/repos","events_url":"https://api.github.com/users/altanis/events{/privacy}","received_events_url":"https://api.github.com/users/altanis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/altanis/infinispan","description":"Infinispan is an open source data grid platform and highly scalable NoSQL cloud data store.","fork":true,"url":"https://api.github.com/repos/altanis/infinispan","forks_url":"https://api.github.com/repos/altanis/infinispan/forks","keys_url":"https://api.github.com/repos/altanis/infinispan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/altanis/infinispan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/altanis/infinispan/teams","hooks_url":"https://api.github.com/repos/altanis/infinispan/hooks","issue_events_url":"https://api.github.com/repos/altanis/infinispan/issues/events{/number}","events_url":"https://api.github.com/repos/altanis/infinispan/events","assignees_url":"https://api.github.com/repos/altanis/infinispan/assignees{/user}","branches_url":"https://api.github.com/repos/altanis/infinispan/branches{/branch}","tags_url":"https://api.github.com/repos/altanis/infinispan/tags","blobs_url":"https://api.github.com/repos/altanis/infinispan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/altanis/infinispan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/altanis/infinispan/git/refs{/sha}","trees_url":"https://api.github.com/repos/altanis/infinispan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/altanis/infinispan/statuses/{sha}","languages_url":"https://api.github.com/repos/altanis/infinispan/languages","stargazers_url":"https://api.github.com/repos/altanis/infinispan/stargazers","contributors_url":"https://api.github.com/repos/altanis/infinispan/contributors","subscribers_url":"https://api.github.com/repos/altanis/infinispan/subscribers","subscription_url":"https://api.github.com/repos/altanis/infinispan/subscription","commits_url":"https://api.github.com/repos/altanis/infinispan/commits{/sha}","git_commits_url":"https://api.github.com/repos/altanis/infinispan/git/commits{/sha}","comments_url":"https://api.github.com/repos/altanis/infinispan/comments{/number}","issue_comment_url":"https://api.github.com/repos/altanis/infinispan/issues/comments/{number}","contents_url":"https://api.github.com/repos/altanis/infinispan/contents/{+path}","compare_url":"https://api.github.com/repos/altanis/infinispan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/altanis/infinispan/merges","archive_url":"https://api.github.com/repos/altanis/infinispan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/altanis/infinispan/downloads","issues_url":"https://api.github.com/repos/altanis/infinispan/issues{/number}","pulls_url":"https://api.github.com/repos/altanis/infinispan/pulls{/number}","milestones_url":"https://api.github.com/repos/altanis/infinispan/milestones{/number}","notifications_url":"https://api.github.com/repos/altanis/infinispan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/altanis/infinispan/labels{/name}","releases_url":"https://api.github.com/repos/altanis/infinispan/releases{/id}","created_at":"2014-08-01T08:58:47Z","updated_at":"2014-08-04T09:01:52Z","pushed_at":"2014-08-05T12:40:07Z","git_url":"git://github.com/altanis/infinispan.git","ssh_url":"git@github.com:altanis/infinispan.git","clone_url":"https://github.com/altanis/infinispan.git","svn_url":"https://github.com/altanis/infinispan","homepage":"http://www.infinispan.org","size":57263,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"infinispan:master","ref":"master","sha":"949093e4385380d87b67823184b9e1e595407f0a","user":{"login":"infinispan","id":458093,"avatar_url":"https://avatars.githubusercontent.com/u/458093?v=2","gravatar_id":"0fb77c892345331382006ea0b2c8a020","url":"https://api.github.com/users/infinispan","html_url":"https://github.com/infinispan","followers_url":"https://api.github.com/users/infinispan/followers","following_url":"https://api.github.com/users/infinispan/following{/other_user}","gists_url":"https://api.github.com/users/infinispan/gists{/gist_id}","starred_url":"https://api.github.com/users/infinispan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infinispan/subscriptions","organizations_url":"https://api.github.com/users/infinispan/orgs","repos_url":"https://api.github.com/users/infinispan/repos","events_url":"https://api.github.com/users/infinispan/events{/privacy}","received_events_url":"https://api.github.com/users/infinispan/received_events","type":"Organization","site_admin":false},"repo":{"id":1050944,"name":"infinispan","full_name":"infinispan/infinispan","owner":{"login":"infinispan","id":458093,"avatar_url":"https://avatars.githubusercontent.com/u/458093?v=2","gravatar_id":"0fb77c892345331382006ea0b2c8a020","url":"https://api.github.com/users/infinispan","html_url":"https://github.com/infinispan","followers_url":"https://api.github.com/users/infinispan/followers","following_url":"https://api.github.com/users/infinispan/following{/other_user}","gists_url":"https://api.github.com/users/infinispan/gists{/gist_id}","starred_url":"https://api.github.com/users/infinispan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infinispan/subscriptions","organizations_url":"https://api.github.com/users/infinispan/orgs","repos_url":"https://api.github.com/users/infinispan/repos","events_url":"https://api.github.com/users/infinispan/events{/privacy}","received_events_url":"https://api.github.com/users/infinispan/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/infinispan/infinispan","description":"Infinispan is an open source data grid platform and highly scalable NoSQL cloud data store.","fork":false,"url":"https://api.github.com/repos/infinispan/infinispan","forks_url":"https://api.github.com/repos/infinispan/infinispan/forks","keys_url":"https://api.github.com/repos/infinispan/infinispan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/infinispan/infinispan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/infinispan/infinispan/teams","hooks_url":"https://api.github.com/repos/infinispan/infinispan/hooks","issue_events_url":"https://api.github.com/repos/infinispan/infinispan/issues/events{/number}","events_url":"https://api.github.com/repos/infinispan/infinispan/events","assignees_url":"https://api.github.com/repos/infinispan/infinispan/assignees{/user}","branches_url":"https://api.github.com/repos/infinispan/infinispan/branches{/branch}","tags_url":"https://api.github.com/repos/infinispan/infinispan/tags","blobs_url":"https://api.github.com/repos/infinispan/infinispan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/infinispan/infinispan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/infinispan/infinispan/git/refs{/sha}","trees_url":"https://api.github.com/repos/infinispan/infinispan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/infinispan/infinispan/statuses/{sha}","languages_url":"https://api.github.com/repos/infinispan/infinispan/languages","stargazers_url":"https://api.github.com/repos/infinispan/infinispan/stargazers","contributors_url":"https://api.github.com/repos/infinispan/infinispan/contributors","subscribers_url":"https://api.github.com/repos/infinispan/infinispan/subscribers","subscription_url":"https://api.github.com/repos/infinispan/infinispan/subscription","commits_url":"https://api.github.com/repos/infinispan/infinispan/commits{/sha}","git_commits_url":"https://api.github.com/repos/infinispan/infinispan/git/commits{/sha}","comments_url":"https://api.github.com/repos/infinispan/infinispan/comments{/number}","issue_comment_url":"https://api.github.com/repos/infinispan/infinispan/issues/comments/{number}","contents_url":"https://api.github.com/repos/infinispan/infinispan/contents/{+path}","compare_url":"https://api.github.com/repos/infinispan/infinispan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/infinispan/infinispan/merges","archive_url":"https://api.github.com/repos/infinispan/infinispan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/infinispan/infinispan/downloads","issues_url":"https://api.github.com/repos/infinispan/infinispan/issues{/number}","pulls_url":"https://api.github.com/repos/infinispan/infinispan/pulls{/number}","milestones_url":"https://api.github.com/repos/infinispan/infinispan/milestones{/number}","notifications_url":"https://api.github.com/repos/infinispan/infinispan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/infinispan/infinispan/labels{/name}","releases_url":"https://api.github.com/repos/infinispan/infinispan/releases{/id}","created_at":"2010-11-04T12:33:19Z","updated_at":"2014-08-04T17:23:46Z","pushed_at":"2014-08-05T17:33:07Z","git_url":"git://github.com/infinispan/infinispan.git","ssh_url":"git@github.com:infinispan/infinispan.git","clone_url":"https://github.com/infinispan/infinispan.git","svn_url":"https://github.com/infinispan/infinispan","homepage":"http://www.infinispan.org","size":122556,"stargazers_count":305,"watchers_count":305,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":251,"mirror_url":null,"open_issues_count":27,"forks":251,"open_issues":27,"watchers":305,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/2773"},"html":{"href":"https://github.com/infinispan/infinispan/pull/2773"},"issue":{"href":"https://api.github.com/repos/infinispan/infinispan/issues/2773"},"comments":{"href":"https://api.github.com/repos/infinispan/infinispan/issues/2773/comments"},"review_comments":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/2773/comments"},"review_comment":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/infinispan/infinispan/pulls/2773/commits"},"statuses":{"href":"https://api.github.com/repos/infinispan/infinispan/statuses/3609e0cd46112bfe64baa059cfee900d11bbef2d"}}}}