Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pablonso opened this issue Oct 16, 2023 · 2 comments

Comments

@pablonso
Copy link

out.writeStringUTF(t.getMessage() != null ? t.getMessage() : "null");

This code converts null String message to "null".

@pablonso
Copy link
Author

pablonso commented Oct 16, 2023

Constructor<? extends Throwable> constructor = objectClass.getConstructor(String.class);

Throwable t = constructor.newInstance(in.readStringUTF()); // This causes stack trace to be filled in twice but not an easy way to solve

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
Copy link
Author

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

workaround worked - override serializer register with alsoForAllSubclasses turned off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant