Bug 335986 - No expected event fired when removing a JAR file from a classpath container
Summary: No expected event fired when removing a JAR file from a classpath container
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-01 11:39 EST by BensonN CLA
Modified: 2011-04-26 10:13 EDT (History)
2 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Proposed fix (4.10 KB, patch)
2011-02-25 04:11 EST, Jay Arthanareeswaran CLA
no flags Details | Diff
Regression test (3.50 KB, patch)
2011-03-06 06:14 EST, Jay Arthanareeswaran CLA
no flags Details | Diff
Fix + Updated tests (6.12 KB, patch)
2011-03-17 02:17 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description BensonN CLA 2011-02-01 11:39:57 EST
Build Identifier: 3.6.2 - M20110105-0951

Our Java EE team created a classpath container for web project, when adding a JAR file to the folder, I can get a JarPackageFragmentRoot is added event with "F_ADDED_TO_CLASSPATH" flag, but when removing it from the same location, I didn't get a similar JarPackageFragmentRoot is removed with "F_REMOVED_FROM_CLASSPATH" event. 

Reproducible: Always

Steps to Reproduce:
1. Creating a classpath container by using JavaCore.setClasspathContainer(...) API.
2.
3.
Comment 1 Olivier Thomann CLA 2011-02-01 11:51:39 EST
Jay, please investigate.
Comment 2 Jay Arthanareeswaran CLA 2011-02-22 04:49:57 EST
The difference between a user library and a web container is in the way libraries get added or removed. In case of user libraries, the user removes the library from the project's build path, in which case, it's very likely that the removed JAR is still physically present. However, in the case of a web container, libraries get added/removed from the resolved classpath by the container. The container is responsible for picking up all the (remaining) JARs from the WEB-INF/lib and updating the classpath. And in this case, the JARs that get removed from the classpath doesn't exist in the file system any longer. Which results in package fragment root being null and hence delta not being reported for individual JAR files. 

I will see if we can get the roots from the cache and report the delta based on that.
Comment 3 Jay Arthanareeswaran CLA 2011-02-25 04:11:49 EST
Created attachment 189778 [details]
Proposed fix

Benson, can you try this patch and confirm if this addresses your concern, while I am trying to add a regression test. Thanks.

Some of the existing tests may need to be updated as well.
Comment 4 BensonN CLA 2011-02-25 09:28:54 EST
Thanks Jay for making the changes, Kim, could you please to give it a try? Thanks
Comment 5 Kim Tsao CLA 2011-02-25 16:04:44 EST
Jay, I tried out your fix and it looks good.
Comment 6 Jay Arthanareeswaran CLA 2011-02-28 06:25:19 EST
(In reply to comment #5)
> Jay, I tried out your fix and it looks good.

Thanks, Kim. I will release the fix after adding some tests.
Comment 7 Jay Arthanareeswaran CLA 2011-03-06 06:14:09 EST
Created attachment 190490 [details]
Regression test

This regression test fails and shows that the fix may not be good enough. This can't go into M6.
Comment 8 Jay Arthanareeswaran CLA 2011-03-17 02:17:19 EDT
Created attachment 191378 [details]
Fix + Updated tests

This patch contains the same fix verified by Kim. However, no new tests have been added. Instead I have used one of the failing test that closely resembles the scenario described by Benson. 

To verify, one must add WST plug-ins and create a dynamic web project.
Comment 9 Jay Arthanareeswaran CLA 2011-04-07 03:30:18 EDT
Olivier, can you spare some time to review this, please?
Comment 10 Olivier Thomann CLA 2011-04-19 15:02:53 EDT
Looks good to me.
Comment 11 Jay Arthanareeswaran CLA 2011-04-20 05:26:29 EDT
Released in HEAD for 3.7 M7.
Comment 12 Olivier Thomann CLA 2011-04-26 10:13:10 EDT
Verified by reporter.