-
-
Notifications
You must be signed in to change notification settings - Fork 11
Fix string deserialize exception #74
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
Conversation
@@ -115,7 +116,7 @@ public void init() { | |||
} catch (Exception e) { | |||
log.error(e.getMessage(), e); | |||
if (e instanceof InvocationTargetException) { | |||
if (e.getCause() instanceof ClassCastException) { | |||
if (e.getCause() instanceof SerializationException || e.getCause() instanceof ClassCastException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wrap the SerializationException
thrown during deserilise to a custom one, so that we can distinguish it from the same thrown in call to serialise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I didn't get your idea, please suggest changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like we need to wrap SerializationException and ClassCastException to something like KevaTypeException
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant we have code like this:
try {
byte[] value = chronicleMap.get(key);
LinkedList<BytesValue> list;
list = value == null ? new LinkedList<>() : (LinkedList<BytesValue>) SerializationUtils.deserialize(value); <- can throw
for (byte[] v : values) {
list.addFirst(new BytesValue(v));
}
chronicleMap.put(key, SerializationUtils.serialize(list)); <- can throw
return list.size();
} finally {
lock.unlock();
}
From 2 places same exception can be thrown but only 1 of them indicates client error.
Although I do agree that serislisation should never throw, but still!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @the123saurav, this is a good suggestion. But it will need to add extra code to every operation method, so I think we should create another issue for that refactoring, and put it to the backlog, after the first release we can resume on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SOunds good!
Hi @the123saurav, created #75 backlog issue for your suggestion |
* fix deserialize string exception * add wrongtype tests
Fixes #73
For String byte[], it doesn't follow the java serialization protocol, thus a SerializationException will be thrown when deserializing on String byte[]