{"action":"opened","issue":{"url":"https://api.github.com/repos/google/protobuf/issues/279","labels_url":"https://api.github.com/repos/google/protobuf/issues/279/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf/issues/279/comments","events_url":"https://api.github.com/repos/google/protobuf/issues/279/events","html_url":"https://github.com/google/protobuf/issues/279","id":67550787,"number":279,"title":"Protobuf doesn't consider identity when serialize/deserialize","user":{"login":"bbonanno","id":241804,"avatar_url":"https://avatars.githubusercontent.com/u/241804?v=3","gravatar_id":"","url":"https://api.github.com/users/bbonanno","html_url":"https://github.com/bbonanno","followers_url":"https://api.github.com/users/bbonanno/followers","following_url":"https://api.github.com/users/bbonanno/following{/other_user}","gists_url":"https://api.github.com/users/bbonanno/gists{/gist_id}","starred_url":"https://api.github.com/users/bbonanno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbonanno/subscriptions","organizations_url":"https://api.github.com/users/bbonanno/orgs","repos_url":"https://api.github.com/users/bbonanno/repos","events_url":"https://api.github.com/users/bbonanno/events{/privacy}","received_events_url":"https://api.github.com/users/bbonanno/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-10T09:23:14Z","updated_at":"2015-04-10T09:23:14Z","closed_at":null,"body":"Given the following unit test\r\n\r\n\r\n      //Given\r\n      Country country = Country.newBuilder()\r\n         .setName(\"Argentina\")\r\n         .build();\r\n\r\n      Exchange exchange = Exchange.newBuilder()\r\n         .setCountry1(country)\r\n         .setCountry2(country)\r\n         .build();\r\n\r\n      //When\r\n      byte[] bytes = exchange.toByteArray();\r\n\r\n      //Then\r\n      Exchange exchange1 = Exchange.parseFrom(bytes);\r\n\r\n      Country country1 = exchange1.getCountry1();\r\n      Country country2 = exchange1.getCountry2();\r\n\r\n      assertThat(country1, sameInstance(country2));\r\n   \r\n\r\nIt would be nice if that assertion was true, unfortunatelly it isn't, I wonder why if I set the same nested message several times the serializer doesn't use a pointer to avoid wasting bytes (every time that I add a reference to the country, the resulting byte[] is bigger by the size of the serialized country +2, what I guess is the serialized field number) into the wire and also maintain identity after deserialize."}}