Community
Participate
Working Groups
using WTP 3.0 In AbstractNestedValidator, there is a setupValidation & teardownValidation method which appears to handle any sort of special setup and cleanup during validation. The xsd & wsdl validator seems to take advantage of these methods to set up grammar pools and configurations so that they can be used for all files in one validation session. This works for the old validation framework because as seen in validateInJob, setup is called, then files are validated, then teardown is called. However, this is not working for the v2 validation framework. Instead, setup and teardown are called within the validate method which is called for each file validated, so it's essentially just setting up and tearing down validation for each file rather than being called once and shared amongst all files being validated. setupvalidation and teardownvalidation need to be called from within the v2 framework's validationStarting and validationFinishing method.
I'll go ahead and assign this to myself and also add that there is currently a bug open on the v2 validation framework that states that the validationStarting and validationFinishing methods are not always called when expected. So bug 243377 should really be fixed first before we fix this one. Also, this bug was found while investigating the fix for bug 243319.
Created attachment 109578 [details] xml.core patch with state - validationStarting is added to AbstractNestedValidator. It gets the existing nestedvalidationcontext if it exists. If not, it creates a new one, calls setupValidation to set the context/validator up, and then stores the context in the validation state so that it can be used later when validate() is called. - validate is modified so that it tries to get the existing nestedvalidationcontext from the validation state. If one does not exist, a new context is created and set up. If one already does exist, then the validator assumes setupValidation has already been called for it. After validating, if a new context was created and set up inside the validate method, teardown is called so that things are cleaned up. - validationFinishing is added to AbstractNestedValidator. It gets the existing nestedvalidationcontext if it exists. If one exists, teardownValidation is called for cleanup and the context is nulled out from validaton state.
To fix this bug but not save anything in validation state, just take the patch and remove all references to "XML_VALIDATOR_CONTEXT" That pretty much defeats the purpose of this bug because setup & teardown will still be called for each validate though. Also, I've found that fixing this bug will expose another problem which will cause a regression in the wsdl & xsd validators. There is an assumption made that if a nestedcontext exists, the delegating validator is already set up. However, currently, a different instance of the delegating validator is being used when validate is called versus when validationStarting and validationFinishing is called. This means the validator is not really set up when validate is called, yet it thinks it is set up because a nestedcontext exists. I'm not sure if the new instance of the delegating validator is intentional or not.