Skip to content
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

Use an ErrorHandler to detect multiple errors #20

Closed
rosslamont opened this issue Aug 10, 2017 · 3 comments
Closed

Use an ErrorHandler to detect multiple errors #20

rosslamont opened this issue Aug 10, 2017 · 3 comments

Comments

@rosslamont
Copy link
Contributor

When using a Schema, and ultimately using one of the Validator.validate methods, the plugin does not properly detect validation failures. When using Validator.validate, the plugin should set an ErrorHandler on the Validator and collect errors that way (and report them at the end). This has the added advantage of collecting and reporting multiple validation problems.

@rosslamont
Copy link
Contributor Author

By way of explanation (sorry for the essay):

The documentation around Validator.validate is a bit dodgy, but the only obligation on a Validator is to throw fatal exceptions. The normal method for Validator.validate to report errors is through an ErrorHandler, and the javadoc on ErrorHandler makes it clear that a validation error is not a fatal exception. What Validator.validate is meant to do if no ErrorHandler is set isn't really contemplated by the javadoc. While its fair to say that it should probably treat validation errors as fatal errors in this circumstance, its certainly not obligated to.

rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 10, 2017
rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 10, 2017
@rosslamont
Copy link
Contributor Author

Fixed in pull request #18

rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 13, 2017
rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 28, 2017
…rrorHandler to detect most validation failures reliably.

To simplify this, existing error handling was refactored to use the more general ErrorHandler added here in all situations.
rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 28, 2017
When using Validator.validate, most validation errors will be ignored. The only reliable way to capture
validation errors is to use an error handler, as Validator.validate only throws fatal errors (validation
errors are not fatal - see javadoc for ErrorHandler)

Solution applied refactors existing error handling approach to always use an ErrorHandler to capture errors.
As a bonus, you should get log messages showing multiple failures, rather than just the first.
rosslamont added a commit to rosslamont/xml-maven-plugin that referenced this issue Aug 28, 2017
When using Validator.validate, most validation errors will be ignored. The only
reliable way to capture validation errors is to use an error handler, as
Validator.validate only throws fatal errors (validation errors are not fatal -
see javadoc for ErrorHandler)

Solution applied refactors existing error handling approach to always use an
ErrorHandler to capture errors. As a bonus, you should get log messages showing
multiple failures, rather than just the first.
@rosslamont rosslamont changed the title Improve validation errors when using a Validator object Validator.validate unreliable without an ErrorHandler Sep 20, 2017
@rosslamont rosslamont changed the title Validator.validate unreliable without an ErrorHandler Use an ErrorHandler to detect multiple errors Sep 20, 2017
@rosslamont
Copy link
Contributor Author

I misread the spec, and the handling of null ErrorHandler is actually specified in the standard.

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

No branches or pull requests

1 participant