RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.58k stars 248 forks source link

Exception with null message after deserialization has String message "null". #344

Open pablonso opened 11 months ago

pablonso commented 11 months ago

https://github.com/RuedigerMoeller/fast-serialization/blob/e8da5591daa09452791dcd992ea4f83b20937be7/src/main/java/org/nustaq/serialization/serializers/FSTThrowableSerializer.java#L16

This code converts null String message to "null".

pablonso commented 11 months ago

https://github.com/RuedigerMoeller/fast-serialization/blob/e8da5591daa09452791dcd992ea4f83b20937be7/src/main/java/org/nustaq/serialization/serializers/FSTThrowableSerializer.java#L27 https://github.com/RuedigerMoeller/fast-serialization/blob/e8da5591daa09452791dcd992ea4f83b20937be7/src/main/java/org/nustaq/serialization/serializers/FSTThrowableSerializer.java#L28

Also wrong constructor is used (when original exception object has null message). Using this constructor deserialized object's message field value will be "null". Moreover - deserialization fails when extended class has no constructor with single String argument.

pablonso commented 11 months ago

serializer.getConfiguration().registerSerializer(Throwable.class, new FSTThrowableSerializer(), false);

workaround worked - override serializer register with alsoForAllSubclasses turned off.