{"action":"created","issue":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/285","labels_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/285/comments","events_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/285/events","html_url":"https://github.com/EsotericSoftware/kryo/issues/285","id":57811475,"number":285,"title":"Cannot remove a Field from FieldSerializer","user":{"login":"seveneves","id":2766429,"avatar_url":"https://avatars.githubusercontent.com/u/2766429?v=3","gravatar_id":"","url":"https://api.github.com/users/seveneves","html_url":"https://github.com/seveneves","followers_url":"https://api.github.com/users/seveneves/followers","following_url":"https://api.github.com/users/seveneves/following{/other_user}","gists_url":"https://api.github.com/users/seveneves/gists{/gist_id}","starred_url":"https://api.github.com/users/seveneves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seveneves/subscriptions","organizations_url":"https://api.github.com/users/seveneves/orgs","repos_url":"https://api.github.com/users/seveneves/repos","events_url":"https://api.github.com/users/seveneves/events{/privacy}","received_events_url":"https://api.github.com/users/seveneves/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-16T14:39:18Z","updated_at":"2015-02-16T15:04:58Z","closed_at":null,"body":"Hi, \r\n\r\nI'm having a custom serializer that extends FieldSerializer. \r\n\r\n```\r\nclass MyCustomSerializer(kryo: Kryo) extends FieldSerializer[MyClass](kryo, classOf[MyClass]) {\r\n\r\n  override def initializeCachedFields(): Unit = {\r\n    getFields.find(_.getField.getName == \"myField\").foreach(field => super.removeField(field.getField.getName))\r\n  }\r\n}\r\n```\r\n\r\nWhen i do that in previous version of kryo, ie 2.21, it worked. it does not with the latest version, 2.24. \r\n\r\nThe problem might be on line 565 when reassigning `fields` array in method `com.esotericsoftware.kryo.serializers.FieldSerializer#removeField(java.lang.String)`\r\n\r\nand then another removal is happening on line 254 of class `com.esotericsoftware.kryo.serializers.FieldSerializer` which results into \r\n\r\n```\r\nField \"myField\" not found on class: com.example.MyClass\r\njava.lang.IllegalArgumentException: Field \"myField\" not found on class: com.example.MyClass\r\n\tat com.esotericsoftware.kryo.serializers.FieldSerializer.removeField(FieldSerializer.java:586)\r\n\tat com.esotericsoftware.kryo.serializers.FieldSerializer.rebuildCachedFields(FieldSerializer.java:254)\r\n\tat com.esotericsoftware.kryo.serializers.FieldSerializer.rebuildCachedFields(FieldSerializer.java:156)\r\n\tat com.esotericsoftware.kryo.serializers.FieldSerializer.<init>(FieldSerializer.java:133)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/comments/74521267","html_url":"https://github.com/EsotericSoftware/kryo/issues/285#issuecomment-74521267","issue_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/285","id":74521267,"user":{"login":"seveneves","id":2766429,"avatar_url":"https://avatars.githubusercontent.com/u/2766429?v=3","gravatar_id":"","url":"https://api.github.com/users/seveneves","html_url":"https://github.com/seveneves","followers_url":"https://api.github.com/users/seveneves/followers","following_url":"https://api.github.com/users/seveneves/following{/other_user}","gists_url":"https://api.github.com/users/seveneves/gists{/gist_id}","starred_url":"https://api.github.com/users/seveneves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seveneves/subscriptions","organizations_url":"https://api.github.com/users/seveneves/orgs","repos_url":"https://api.github.com/users/seveneves/repos","events_url":"https://api.github.com/users/seveneves/events{/privacy}","received_events_url":"https://api.github.com/users/seveneves/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T15:04:58Z","updated_at":"2015-02-16T15:04:58Z","body":"Seems, the custom impletation chaged and now protected field `removedFeilds` has to be used. \r\n\r\nI suppose correct code has to be written as \r\n\r\n```\r\nclass MyCustomSerializer(kryo: Kryo) extends FieldSerializer[MyClass](kryo, classOf[MyClass]) {\r\n\r\n  override def initializeCachedFields(): Unit = {\r\n    getFields.find(_.getField.getName == \"myField\").foreach(removedFields.add)\r\n  }\r\n}\r\n```"}}