Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313800

Summary: Add resource checking in Validation framework to avoid resource exceptions
Product: [WebTools] WTP Common Tools Reporter: Wini Mark <wmmark>
Component: wst.validationAssignee: Wini Mark <wmmark>
Status: CLOSED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc, jsholl, karasiuk, raghunathan.srinivasan, thatnitind, valentinbaciu
Version: 3.2Flags: 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+
Target Milestone: 3.2 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
Add the check of resource.exists()
none
Add the check of resource.isAccessible() none

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.