Improvement #304

DefaultDeserializer should not throw ClassCastException on invalid input

Added by Philipp Buluschek over 3 years ago. Updated over 3 years ago.

Status:New Start date:02/26/2015
Priority:Normal Due date:
Assignee:- % Done:


Category:- Spent time: -
Target version:-
Has a patch:No Has license agreement signed:No


When deserializing a boolean from a byte, if the value is not 1 or 0, the deserializer throws a ClassCastException (as it tries to cast Integers.INVALID_OBJECT to a Boolean).

I suppose Integers.readBooleanObject() should throw an IllegalArgumentException and return a Boolean.


#1 Updated by Philipp Buluschek over 3 years ago

Additionally, the primitive method readBoolean(byte[] src, int pos) behaves differently (and also surprisingly).

For value 1, it return true, for any other value false. It should either throw if the value is not 0 or 1 (see above) or return true for any value not 0 (which is the way it's done in C/C++)

Also available in: Atom PDF