Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313800 - Add resource checking in Validation framework to avoid resource exceptions
Summary: Add resource checking in Validation framework to avoid resource exceptions
Status: CLOSED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.validation (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC3   Edit
Assignee: Wini Mark CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 15:31 EDT by Wini Mark CLA
Modified: 2010-06-16 13:24 EDT (History)
6 users (show)

See Also:
ccc: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
ccc: pmc_approved? (naci.dai)
deboer: pmc_approved+
ccc: pmc_approved? (neil.hauge)
ccc: pmc_approved? (kaloyan)
karasiuk: review+
ccc: review+


Attachments
Add the check of resource.exists() (1.29 KB, patch)
2010-05-20 15:51 EDT, Wini Mark CLA
no flags Details | Diff
Add the check of resource.isAccessible() (1.30 KB, patch)
2010-05-26 15:55 EDT, Wini Mark CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wini Mark CLA 2010-05-20 15:31:38 EDT
Build Identifier: WTP 3.2

Got the following exception in the .log file :

org.eclipse.core.internal.resources.ResourceException: Resource '/MinibankEJB/ejbModule/com/ibm/websphere/csi/_TransactionalObject_Stub.class' does not exist.
        at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:317)
        at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:194)
        at org.eclipse.core.internal.resources.Resource.checkAccessibleAndLocal(Resource.java:200)
        at org.eclipse.core.internal.resources.Resource.setSessionProperty(Resource.java:1640)
        at org.eclipse.wst.validation.internal.ValManager.putValProperty(ValManager.java:919)

We can add a check of the resource in the ValManager class to make sure the resource exists. 

Reproducible: Always
Comment 1 Wini Mark CLA 2010-05-20 15:51:12 EDT
Created attachment 169407 [details]
Add the check of resource.exists()
Comment 2 Carl Anderson CLA 2010-05-26 11:28:13 EDT
I approve of this change.
Comment 3 Wini Mark CLA 2010-05-26 11:40:16 EDT
The problem is the validation framework didn't check if the resource does exist or not before doing the validation on the resource.  If a resource is deleted by the user while the validation is running, the ResourceException message will be logged.  

There is no workaround.

The fix is to add a checking in the validation framework to check if the resource exists. The fix is very simple and safe. I tested it by deleting a resource during validation and there is no exception logged. Also ran the test (manual and build validation) to ensure no regression.
Comment 4 Nitin Dahyabhai CLA 2010-05-26 13:13:40 EDT
Resource#setSessionProperty() is calling Resource#checkAccessible(), not just Resource#checkExists() directly.  Shouldn't we then call IResource.isAccessible() as well?
Comment 5 Wini Mark CLA 2010-05-26 15:55:07 EDT
Created attachment 170089 [details]
Add the check of resource.isAccessible()
Comment 6 Carl Anderson CLA 2010-05-26 15:59:09 EDT
Nitin is correct - checking to see isAccessible() will prevent this from being done on closed projects.

I approve of the updated patch.
Comment 7 Carl Anderson CLA 2010-05-27 13:30:59 EDT
Committed to HEAD for WTP 3.2 RC3
Comment 8 Valentin Baciu CLA 2010-06-16 13:24:38 EDT
Closing.