{"id":41808804,"url":"https://github.com/venth/kryo-different_object_versions_handling","last_synced_at":"2026-01-25T06:57:12.175Z","repository":{"id":21493107,"uuid":"24812004","full_name":"venth/kryo-different_object_versions_handling","owner":"venth","description":"The goal is to check, how kryo and java handles deserialization to a different version of class of an object. ","archived":false,"fork":false,"pushed_at":"2015-05-29T19:08:04.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-17T09:07:55.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/venth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-05T08:56:20.000Z","updated_at":"2020-08-28T16:17:56.000Z","dependencies_parsed_at":"2022-08-17T18:00:55.935Z","dependency_job_id":null,"html_url":"https://github.com/venth/kryo-different_object_versions_handling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/venth/kryo-different_object_versions_handling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venth%2Fkryo-different_object_versions_handling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venth%2Fkryo-different_object_versions_handling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venth%2Fkryo-different_object_versions_handling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venth%2Fkryo-different_object_versions_handling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/venth","download_url":"https://codeload.github.com/venth/kryo-different_object_versions_handling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venth%2Fkryo-different_object_versions_handling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28747306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T05:12:38.112Z","status":"ssl_error","status_checked_at":"2026-01-25T05:04:50.338Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-25T06:57:11.324Z","updated_at":"2026-01-25T06:57:12.169Z","avatar_url":"https://github.com/venth.png","language":"Groovy","readme":"kryo different object versions handling\n=======================================\n\nThe goal is to check, how kryo and java handles deserialization to a different version of class of an object.\nI've checked java serialization to see how much java serialization is tolerant.\n\n## Kryo Scenarios\n\n1. object deserialized to new version of class sets new fields to null\n2. deserialization to new class version sets old fields\n3. deserialization object of new class to the object of old class sets only old fields\n\nThe scenarios are supported by: KryoSerializationObjectWithDifferentVersionsTest\n \n## Java Scenarios\n\n1. object deserialized to new version of class sets new fields to null\n2. deserialization to new class version sets old fields\n3. deserialization to class version with missing fields sets only existing fields\n4. cannot deserialize to class version with different field type\n5. deserialization object of new class to the object of old class sets only old fields\n6. deserialization object of class with additional field to the object of the old class with different field sequence sets only old fields\n\nThe scenarios are supported by: JavaSerializationTest \n\n## Model classes\n\n* Base model (first version)\n\n```java\n    \n    public class VersionedModel implements Serializable {\n        private static final long serialVersionUID = 8492539216375372328L;\n        public String firstStringField;\n        public int firstPrimitiveField;\n    }\n    \n```\n\n* Model with additional fields (there are kryo annotations there, not relevant in java scenarios)\n\n```java\n\n    public class VersionedModel implements Serializable {\n    \n        private static final long serialVersionUID = 8492539216375372328L;\n    \n        public String firstStringField;\n        public int firstPrimitiveField;\n    \n        @FieldSerializer.Optional(\"secondStringField\")\n        public String secondStringField;\n        @FieldSerializer.Optional(\"secondPrimitiveField\")\n        public int secondPrimitiveField;\n    }\n\n```\n\n* Model with a missing field firstStringField\n\n```java\n\n    public class VersionedModel implements Serializable {\n        private static final long serialVersionUID = 8492539216375372328L;\n        public int firstPrimitiveField;\n    }\n\n```\n\n* The model has firstPrimitiveField type changed to float (this shall have a different serail version uuid, but I kept the same by purpose)\n\n```java\n\n    public class VersionedModel implements Serializable {\n        private static final long serialVersionUID = 8492539216375372328L;\n    \n        public String firstStringField;\n        public float firstPrimitiveField;\n    }\n\n```\n\n* The model with switched field sequence int field is at the begging now\n\n```java\n\n    public class VersionedModel implements Serializable {\n        private static final long serialVersionUID = 8492539216375372328L;\n        public int firstPrimitiveField;\n        public String firstStringField;\n    }\n    \n```\n\n## Tests launch\n\nTests can be launched by: mvn clean package\n\nThe libraries containing model class must be created. They are copied by\nmaven dependency plugin to the test classpath. Thanks to their location, they're\nloaded by tests and used to instantiate multiple different model classes at the same time.\n\n## Conclusions\n* Kryo serialization is tolerant and needs fields to be additionally annotated, not metioning kryo class registry\n* Java serialization is tolerant, if the serial version uuid number is managed manually\n    * the number has to be changed only, if any of serialized fields is changed its type or\n     the serial version id may be left untouched, if there will be a special implementation\n     of deserialization. Either way, this situation must be somehow solved\n    * other cases:\n        * missing fields,\n        * additional fields,\n        * different fields sequence isn't relevant from serialization / deserialization point of view, but\n        it's important during service handling\n        ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fventh%2Fkryo-different_object_versions_handling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fventh%2Fkryo-different_object_versions_handling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fventh%2Fkryo-different_object_versions_handling/lists"}