Closed Warkeeper closed 4 years ago
BTW, It works fine if I register void.class Class.class SomeClass.class.
This also works if you use Void.class
and not the primitive void.class
. Is that an option in your case?
I quickly checked the code and it is possible to fix this but not without breaking serialization compatibility.
Thanks for reply. @theigl It's difficult to use Void.class instead of void.class in my case because I'm using kryo in a RPC framework and void.class may appear in user's return type (or even in arguments) which framework can not control. Is there any possibility to fix it without breaking compatibility ? I could work around it in my framework, but I think it may be better if kryo could solve it.
@Warkeeper: I just checked again. Fixing this is currently only possible by registering a new serializer for the primitive void
and that breaks backwards compatibility because class registration IDs change. This is something that could be added in the next major release.
For now, please work around this by registering void.class
manually.
Isn't this the way kryo expects to deal with application specific requirements? So while kryo could register it by default, it's ok and not a workaround if that's done here by the application.
That's true, but all other primitive types are registered automatically: https://github.com/EsotericSoftware/kryo/blob/ac091570e43ea74891ca297fc8414f4b08190855/src/com/esotericsoftware/kryo/Kryo.java#L230
Not registering void
by default could be intentional because it is typically not used a lot, but it could also be an oversight.
Ok. Closed for now, please reopen if this is still an issue.
Environment
Steps to reproduce this issue
Expected Result
Nothing goes wrong, I got the proper deserialized object.
Actual Result
An exception is thrown when kryo is reading object.
Exception trace:
Codes to reproduce this issue