payload: {"action":"created","issue":{"url":"https://api.github.com/repos/protostuff/protostuff/issues/266","repository_url":"https://api.github.com/repos/protostuff/protostuff","labels_url":"https://api.github.com/repos/protostuff/protostuff/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/protostuff/protostuff/issues/266/comments","events_url":"https://api.github.com/repos/protostuff/protostuff/issues/266/events","html_url":"https://github.com/protostuff/protostuff/issues/266","id":433370031,"node_id":"MDU6SXNzdWU0MzMzNzAwMzE=","number":266,"title":"Protostuff reorder array with null values upon deser","user":{"login":"koen-serneels","id":1129913,"node_id":"MDQ6VXNlcjExMjk5MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1129913?v=4","gravatar_id":"","url":"https://api.github.com/users/koen-serneels","html_url":"https://github.com/koen-serneels","followers_url":"https://api.github.com/users/koen-serneels/followers","following_url":"https://api.github.com/users/koen-serneels/following{/other_user}","gists_url":"https://api.github.com/users/koen-serneels/gists{/gist_id}","starred_url":"https://api.github.com/users/koen-serneels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koen-serneels/subscriptions","organizations_url":"https://api.github.com/users/koen-serneels/orgs","repos_url":"https://api.github.com/users/koen-serneels/repos","events_url":"https://api.github.com/users/koen-serneels/events{/privacy}","received_events_url":"https://api.github.com/users/koen-serneels/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-04-15T16:20:36Z","updated_at":"2019-04-17T21:17:14Z","closed_at":null,"author_association":"NONE","body":"Hi. Protostuff seems to 'reorder' positions in an array, at least when 'null' values are involved:\r\n\r\n```\r\n          System.setProperty(\"protostuff.runtime.always_use_sun_reflection_factory\", \"true\");\r\n\t  System.setProperty(\"protostuff.runtime.collection_schema_on_repeated_fields\", \"true\")\r\n\t  System.setProperty(\"protostuff.runtime.use_sun_misc_unsafe\", \"false\");\r\n\r\n\t   class Something {\r\n\t\t\tprivate Object[] o;\r\n\t\t}\r\n\r\n\t\tSomething something = new Something();\r\n\t\tsomething.o = new Object[] { new Long(1), \"testA\", null, \"testB\" };\r\n\r\n\t\tSchema schema = RuntimeSchema.createFrom(Something.class);\r\n\t\tLinkedBuffer buffer = LinkedBuffer.allocate(512);\r\n\t\tByteArrayOutputStream bos = new ByteArrayOutputStream();\r\n\t\tfinal byte[] protostuff;\r\n\t\ttry {\r\n\t\t\tprotostuff = ProtostuffIOUtil.toByteArray(something, schema, buffer);\r\n\t\t\tbos.write(protostuff);\r\n\t\t} finally {\r\n\t\t\tbuffer.clear();\r\n\t\t\tbos.close();\r\n\t\t}\r\n\t\tschema = RuntimeSchema.getSchema(Something.class);\r\n\t\tSomething result = (Something) schema.newMessage();\r\n\t\tProtostuffIOUtil.mergeFrom(new ByteArrayInputStream(bos.toByteArray()), result, schema);\r\n```\r\nIn the derserialized array the order is '1', 'testA', 'testB' , null. What are we missing? Is this a bug, a setting that is not there?"},"comment":{"url":"https://api.github.com/repos/protostuff/protostuff/issues/comments/484264987","html_url":"https://github.com/protostuff/protostuff/issues/266#issuecomment-484264987","issue_url":"https://api.github.com/repos/protostuff/protostuff/issues/266","id":484264987,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4NDI2NDk4Nw==","user":{"login":"koen-serneels","id":1129913,"node_id":"MDQ6VXNlcjExMjk5MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1129913?v=4","gravatar_id":"","url":"https://api.github.com/users/koen-serneels","html_url":"https://github.com/koen-serneels","followers_url":"https://api.github.com/users/koen-serneels/followers","following_url":"https://api.github.com/users/koen-serneels/following{/other_user}","gists_url":"https://api.github.com/users/koen-serneels/gists{/gist_id}","starred_url":"https://api.github.com/users/koen-serneels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koen-serneels/subscriptions","organizations_url":"https://api.github.com/users/koen-serneels/orgs","repos_url":"https://api.github.com/users/koen-serneels/repos","events_url":"https://api.github.com/users/koen-serneels/events{/privacy}","received_events_url":"https://api.github.com/users/koen-serneels/received_events","type":"User","site_admin":false},"created_at":"2019-04-17T21:17:14Z","updated_at":"2019-04-17T21:17:14Z","author_association":"NONE","body":"Did that, but no go:\r\n`\r\nimport java.io.ByteArrayInputStream;\r\nimport java.io.ByteArrayOutputStream;\r\n\r\nimport io.protostuff.LinkedBuffer;\r\nimport io.protostuff.ProtostuffIOUtil;\r\nimport io.protostuff.Schema;\r\nimport io.protostuff.runtime.RuntimeSchema;\r\n\r\npublic class SerializationTest {\r\n\r\n\tpublic static void main(String[] args) throws Exception {\r\n\r\n\t\tclass Something {\r\n\t\t\tprivate Object[] o;\r\n\t\t}\r\n\r\n\t\tSomething something = new Something();\r\n\t\tsomething.o = new Object[] { new Long(1), \"testA\", null, \"testB\" };\r\n\r\n\t\tSchema schema = RuntimeSchema.createFrom(Something.class);\r\n\t\tLinkedBuffer buffer = LinkedBuffer.allocate(512);\r\n\t\tByteArrayOutputStream bos = new ByteArrayOutputStream();\r\n\t\tfinal byte[] protostuff;\r\n\t\ttry {\r\n\t\t\tprotostuff = ProtostuffIOUtil.toByteArray(something, schema, buffer);\r\n\t\t\tbos.write(protostuff);\r\n\t\t} finally {\r\n\t\t\tbuffer.clear();\r\n\t\t\tbos.close();\r\n\t\t}\r\n\t\tschema = RuntimeSchema.getSchema(Something.class);\r\n\t\tSomething result = (Something) schema.newMessage();\r\n\t\tProtostuffIOUtil.mergeFrom(new ByteArrayInputStream(bos.toByteArray()), result, schema);\r\n\r\n\t\tSystem.out.println(\"Should be: 1 - testA - null - TestB\");\r\n\t\tSystem.out.println(\"Actual result: \" + result.o[0] + \" - \" + result.o[1] + \" - \" + result.o[2] + \" - \" + result.o[3]);\r\n\t}\r\n}\r\n\r\n`\r\n>  2019-04-17 23:15:29 ⌚  koen-HP-ZBook-15-G3 in /tmp\r\n> ○ → java -version\r\n> java version \"1.8.0_151\"\r\n> Java(TM) SE Runtime Environment (build 1.8.0_151-b12)\r\n> Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)\r\n> \r\n>  2019-04-17 23:15:31 ⌚  koen-HP-ZBook-15-G3 in /tmp\r\n> ○ → java -Dprotostuff.runtime.always_use_sun_reflection_factory=true -Dprotostuff.runtime.collection_schema_on_repeated_fields=true -Dprotostuff.runtime.use_sun_misc_unsafe=false -Dprotostuff.runtime.allow_null_array_element=true -cp ./:protostuff-uberjar-1.5.9.jar SerializationTest\r\n> Should be: 1 - testA - null - TestB\r\n> Actual result: 1 - testA - testB - null\r\n> \r\n>  2019-04-17 23:15:45 ⌚  koen-HP-ZBook-15-G3 in /tmp\r\n> ○ → \r\n> "}}
other: {"actor":{"display_login":"koen-serneels"}}