We have a distributed exception handling system, which treats the distributed exceptions as local.
For the following case:
private static class UnSerializedClass {}
private static class MyCustomException extends RuntimeException {
private UnSerializedClass unSerializedClass = new UnSerializedClass();
}
Our system may use FST to serialize MyCustomException and it's going fail because of the unserializable field UnSerializedClass . But our system shouldn't fail and should pack the stack messages as the serialized object.
Now, our implementation like the following code:
byte[] serializedException;
try {
serializedException = Fst.encode(exception);
} catch (RuntimeException e) {
if (e.getMsg().contains("does not implement xxxx")) {
serializedException = Fst.encode(Utils.getStackTrace(exception));
} else {
// xxx
}
}
// send this `serializedException` bytes to the others.
So, it's necessary to have the new class SerializableNotImplementException(or other class name), to let user code clean:
byte[] serializedException;
try {
serializedException = Fst.encode(exception);
} catch (SerializableNotImplementException e) {
serializedException = Fst.encode(Utils.getStackTrace(exception));
}
// send this `serializedException` bytes to the others.
https://github.com/RuedigerMoeller/fast-serialization/blob/master/src/main/java/org/nustaq/serialization/FSTClazzInfo.java#L143
We have a distributed exception handling system, which treats the distributed exceptions as local. For the following case:
Our system may use FST to serialize
MyCustomException
and it's going fail because of the unserializable fieldUnSerializedClass
. But our system shouldn't fail and should pack the stack messages as the serialized object. Now, our implementation like the following code:So, it's necessary to have the new class
SerializableNotImplementException
(or other class name), to let user code clean: