This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 84010 - Exception when performing Validation and Undo concurrently
Summary: Exception when performing Validation and Undo concurrently
Status: VERIFIED FIXED
Alias: None
Product: soa
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Praveen Savur
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-01 12:41 UTC by Mikhail Kondratyev
Modified: 2006-09-17 12:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Kondratyev 2006-09-01 12:41:52 UTC
Steps to reproduce:
 - create a new Sync process
 - add several new elements to the process
 - click Validate button in the toolbar and then quickly click Ctrl+Z several
times. The following exception will be thrown:
java.util.ConcurrentModificationException
	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:374)
	at java.util.AbstractList$Itr.next(AbstractList.java:345)
	at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1014)
	at
org.netbeans.modules.bpel.model.impl.BpelEntityImpl.acceptChildren(BpelEntityImpl.java:338)
	at
org.netbeans.modules.bpel.model.impl.BpelEntityImpl.accept(BpelEntityImpl.java:206)
	at
org.netbeans.modules.bpel.model.validation.imports.BPELImportsValidator.validate(BPELImportsValidator.java:78)
	at org.netbeans.modules.xml.xam.spi.Validation.validate(Validation.java:78)
	at
org.netbeans.modules.xml.validation.ValidationOutputWindowController.validate(ValidationOutputWindowController.java:64)
	at
org.netbeans.modules.xml.validation.ValidateAction$RunAction.run(ValidateAction.java:88)
	at
org.netbeans.modules.bpel.editors.multiview.DesignerMultiViewElement$BPELValidateAction$1.run(DesignerMultiViewElement.java:718)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:499)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:932)
Comment 1 Denis Anisimov 2006-09-01 13:19:39 UTC
This is obvious problem for me.
I don't know why it was not noticed on first state of Validation framework 
development.

This is very easy problem :
- validation is performed in its own thread.
- OM modification is performed in AWT thread.

Validation doesn't perform OM blocking ( WHY ????? ). So two thread perform 
access to shared resource ( OM ) concurrently.

I can understand the reason why Validation doesn't perform OM blocking but
this problem was just ignored at all.

I see here two desicions:
1) perform blocking OM. But in this case you need to know that 
calling method validate in ValidationOutputWindowController class
could not work as expected.

    public List<ResultItem> validate(Model model) {
        
        // Ensure the model is in sync.
        if (model!=null && !model.inSync()) {
            try {
                model.sync();
            } catch (IOException ioe) {
                // Ignore and let the validator discover the error
                // and report it to the user.
            }
        }

If this method will be placed at transaction then ( at least in BPEL OM ) 
calling "model.sync()" will not have any effect ( this is by design ).
I believe in other models ( Schema, WSDL ) calling "model.sync()"
will throw exception ( because one transaction already was started and 
sync() starts one more transaction ).
So model.sync() should not be called inside transaction if you want some result
from this calling.
2) Validation should be interrupted as soon as OM mutation appears.
I don't know how easy this can be done.
I see here some set of problems.
One of problem: validation starts walking through all OM tree via visitors.
In this case each method "visit" in visitor should check started mutation of OM.
This is very hard logic for source code. 

May be the best way here will be combination of this two approaches :
common validation framework should not block OM,
framework first of all should perform blocking of OM each time when new
validator is started , then starts validation inside this block.
In this case we will have OM integrity for each validator.
But OM can be mutated between various validators work.
I think this is acceptable and at least this is not buggy.
Comment 2 Praveen Savur 2006-09-02 00:16:40 UTC
In case of automatic validation this is being done in a central place. So this
problem does not exist.

For the manual (slow) validation currently no locks are being obtained. Yes,
best fix is for each BPEL validator to get a lock before it begins validating
for the slow validation case.

Comment 3 Ritesh Adval 2006-09-06 01:52:20 UTC
bpel validation bug, changing subcomponent.

should we create a new subcomponent called "validation" ?
Comment 4 Praveen Savur 2006-09-09 00:16:06 UTC
Fixed. Each type of bpel validator now locks the model while doing validation to
avoid concurrent mutations. 

There is still a possibility that the model could be mutated between each
validator running. For deleted elements message like below will be shown.

C:/temp2/SynchronousSample/src/SynchronousSample.bpel: Position unavailable. The
file could have been modified during validation.



Comment 5 Mikhail Kondratyev 2006-09-17 12:53:59 UTC
Verified in build from 2006.09.15