Details
Description
If an Exception occurs in the getValue of a field during marshalling, it is hidden in a catch with no logging and exception. For example, if an exception if thrown with the value for field "name" is gotten with "getValue", it is wrapped in an InvocationTargetException (from the invocation using reflection) and then in a CastorInvalidStateException (see FieldHandlerImpl.java:454 and 458).
When the CastorInvalidStateException gets back to the Marshaller, it is squashed completely on line 1716:
try
{ obj = elemDescriptor.getHandler().getValue(object); }catch(IllegalStateException ise)
{ continue; }In one case, my getXXX method did a DB query, which failed but there was nothing reported. In another case, there was a class loading problem, and again, nothing was reported.
I think at least a error log of some sort is required. I would prefer to see a MarshallingException thrown, wrapping the original Exception.
Issue Links
- is related to
-
CASTOR-1691
Implement a way to allow Castor to report un/marshaling exceptions
-
Adding a patch.
I'm not sure if anyone relies on the "Skip if error" behavior for marshaling: To me is seems "bad" is it could result in invalid XML. Thus I would prefer to see an exception. If I had to set a flag to get that behavior, that would be fine.