Bug 243449 - AbstractNestedValidator: setup and teardown validation is called for each file validated
Summary: AbstractNestedValidator: setup and teardown validation is called for each fil...
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: wst.xml-triaged CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords: performance
Depends on: 243377
Blocks:
  Show dependency tree
 
Reported: 2008-08-07 12:15 EDT by Amy Wu CLA
Modified: 2013-06-19 11:13 EDT (History)
3 users (show)

See Also:


Attachments
xml.core patch with state (4.45 KB, patch)
2008-08-08 18:34 EDT, Amy Wu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Wu CLA 2008-08-07 12:15:34 EDT
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.
Comment 1 Amy Wu CLA 2008-08-07 12:18:23 EDT
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.
Comment 2 Amy Wu CLA 2008-08-08 18:34:37 EDT
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.
Comment 3 Amy Wu CLA 2008-08-08 19:12:20 EDT
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.