Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Unmarshalling Error Counter is causing unclear exceptions #1139

Open
facundovs opened this issue Sep 13, 2017 · 1 comment
Open

Unmarshalling Error Counter is causing unclear exceptions #1139

facundovs opened this issue Sep 13, 2017 · 1 comment

Comments

@facundovs
Copy link

facundovs commented Sep 13, 2017

Hi Guys.

I was testing the JAXB Unmarshalling feature, and I could find that after this improvement an errorCounter was added for throwing a generic exception after ten unmarshalling errors.
This behaviour can be easily reproduced with this test case (if needed, clone the repository and run mvn clean install).
However I think this behavior has some limitations and a better approach could be taken.
If you need to use JAXB to unmarshall differents xml files in differents scenarios, after the tenth try, you will only have an unclear and generic exception with the following message:

Errors limit exceeded. To receive all errors set com.sun.xml.bind logger to FINEST level.

This message doesn't have any information about the unmarshalling. The traceability of the error is very poor! I know that the case that caused this improvement was about an scenario where the same xml was unmarshalled many times but scenarios where differents xml are unmarshalled should also be considered. It is also important because the JaxbException is propagated in frameworks like CXF, and after the tenth try, the final user can't get a clear exception.
I also know a workaround could be setting the log level to FINEST, but it results in a verbose logging as a side effect.
I have read that the improvement was caused by a performance problem in that the exception message was formatted over and over, but a caching strategy could be a better approach to avoid formatting identical messages more than once.
Lastly, It would be nice, at least, to able to configure if an error limit should be applied through the API or a system property instead through the log level.

Thanks and Regards.

@facundovs
Copy link
Author

Hi guys. Could you review this issue? I have sent this PR that makes the errorCounter customizable.

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

No branches or pull requests

1 participant