{"action":"created","issue":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/291","repository_url":"https://api.github.com/repos/EsotericSoftware/kryo","labels_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/291/comments","events_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/291/events","html_url":"https://github.com/EsotericSoftware/kryo/issues/291","id":60510429,"number":291,"title":"Improve field removal in CompatibleFieldSerializer","user":{"login":"solf","id":106305,"avatar_url":"https://avatars.githubusercontent.com/u/106305?v=3","gravatar_id":"","url":"https://api.github.com/users/solf","html_url":"https://github.com/solf","followers_url":"https://api.github.com/users/solf/followers","following_url":"https://api.github.com/users/solf/following{/other_user}","gists_url":"https://api.github.com/users/solf/gists{/gist_id}","starred_url":"https://api.github.com/users/solf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solf/subscriptions","organizations_url":"https://api.github.com/users/solf/orgs","repos_url":"https://api.github.com/users/solf/repos","events_url":"https://api.github.com/users/solf/events{/privacy}","received_events_url":"https://api.github.com/users/solf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2015-03-10T14:45:10Z","updated_at":"2016-06-29T00:48:29Z","closed_at":null,"body":"This is an extension of https://github.com/EsotericSoftware/kryo/issues/286\r\n\r\nPlease improve removed field handling in CompatibleFieldSerializer so that it is actually possible to remove fields (rather than having to keep them indefinitely for backward compatibility).\r\n\r\nConsider the patch I've come up with: https://copy.com/akbTt9twsSr2CNqU\r\nAnd second patch to force exception on missing fields (avoids risk on incorrect de-serialization; must be applied after patch above): https://copy.com/hk1YcLDhxqfMaylJ\r\n\r\nThis does two things:\r\n- Obsolete fields can be removed into inner(nested) class (ObsoleteKryoFields) that ought to be static + private. This way these obsolete fields don't consume any memory when instantiating original class and don't clutter its code (other than the inner class itself).\r\n- If there are obsolete fields during de-serialization, then if class declares 'private transient ObsoleteKryoFields obsoleteKryoFields' field, then its value will be set to the instance holding obsolete fields (thus an easy support for migrating obsolete values into their new 'homes'). This also works across superclasses (hence the requirement for the field to be 'private').\r\n\r\nIf there are no actual obsolete fields in the data being de-serialized, then the performance hit is minimal.\r\n\r\nFor testing/demonstration:\r\n- Start with http://pastebin.com/e8RpFkfm -- create serialized data on disk.\r\n- Test with something like this: http://pastebin.com/9eWD0vha You can also remove/comment out ObsoleteKryoFields inner class(es) and watch how de-serialization fails when fields are removed without this additional support."},"comment":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/comments/229226450","html_url":"https://github.com/EsotericSoftware/kryo/issues/291#issuecomment-229226450","issue_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/291","id":229226450,"user":{"login":"cuihz","id":3721691,"avatar_url":"https://avatars.githubusercontent.com/u/3721691?v=3","gravatar_id":"","url":"https://api.github.com/users/cuihz","html_url":"https://github.com/cuihz","followers_url":"https://api.github.com/users/cuihz/followers","following_url":"https://api.github.com/users/cuihz/following{/other_user}","gists_url":"https://api.github.com/users/cuihz/gists{/gist_id}","starred_url":"https://api.github.com/users/cuihz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuihz/subscriptions","organizations_url":"https://api.github.com/users/cuihz/orgs","repos_url":"https://api.github.com/users/cuihz/repos","events_url":"https://api.github.com/users/cuihz/events{/privacy}","received_events_url":"https://api.github.com/users/cuihz/received_events","type":"User","site_admin":false},"created_at":"2016-06-29T00:48:28Z","updated_at":"2016-06-29T00:48:28Z","body":"@diaimm I tried your FieldMappingCompatibleSerializer. I create a class with two fields x and y. They are all int array(int[]). Then, I create an instance of the class called p, set x a value and setY(p.getX()). I write p to a file by kryo. Then I removed field x and read the file by kryo ,  I get an Exception.\r\n\r\nException in thread \"main\" com.esotericsoftware.kryo.KryoException: Buffer underflow.\r\n\tat com.esotericsoftware.kryo.io.Input.require(Input.java:199)\r\n\tat com.esotericsoftware.kryo.io.Input.readAscii_slow(Input.java:616)\r\n\tat com.esotericsoftware.kryo.io.Input.readAscii(Input.java:594)\r\n\tat com.esotericsoftware.kryo.io.Input.readString(Input.java:472)\r\n\tat com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:150)\r\n\tat com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:133)\r\n\tat com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:670)\r\n\tat com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:781)\r\n\r\n"}}
{"actor":{"display_login":"cuihz"}}