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

Bug 345220

Summary: Duplicate results returned by ClassLoader.getResources()
Product: [RT] Virgo Reporter: Brad Chen <brad5620732>
Component: runtimeAssignee: Violeta Georgieva <milesg78>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: brad5620732, eclipse, glyn.normington
Version: unspecified   
Target Milestone: 3.0.0.M05   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 346431    
Bug Blocks: 347955    
Attachments:
Description Flags
Test bundle with an empty class and a resource file
none
Test web application that gets the resource none

Description Brad Chen CLA 2011-05-09 21:09:09 EDT
Build Identifier: 2.1.0, 2.1.1, 3.0.0.M03

When loading resources from other bundles using thread context class loader's getResources() method, duplicate results would be given. For example, running the following line in a servlet results in 2 faces-config.xml files to be returned:

Thread.currentThread().getContextClassLoader().getResources("META-INF/faces-config.xml");

Also, not sure if this is a bug, when trying to reproduce this bug, I noticed that getResources() can only load resources from a bundle that has classes. Any bundle without classes, but only the resources, would result in the bundle being ignored by getResources().

This bug may result in duplicate phase listeners to be registered in a JSF environment. As such, this bug was originally filed to MyFaces (https://issues.apache.org/jira/browse/MYFACES-3055).

Reproducible: Always

Steps to Reproduce:
1. Set up a bundle that has an empty class and a resource file.
2. Make sure the package of the empty class is exported.
3. Set up a web bundle that imports the package exported in step 2.
4. Create a servlet and run Thread.currentThread().getContextClassLoader().getResources("path to the resource file"). Notice that 2 entries would be returned.
Comment 1 Violeta Georgieva CLA 2011-05-11 07:33:02 EDT
Created attachment 195327 [details]
Test bundle with an empty class and a resource file

This bundle has:
- an empty class
- a resource file
- exports the class' package
Comment 2 Violeta Georgieva CLA 2011-05-11 07:38:52 EDT
Created attachment 195329 [details]
Test web application that gets the resource

The test web application:
- imports the package exported by the test bundle.
- has a servlet that invokes TCC.getResources("test.resource").
- The request URL is http://localhost:8080/testweb
- the servlet prints the results in System.err, so in the <Virgo-Home-Dir>/serviceability/logs/testweb-0.0.0/log.log, one can see that two URLs are returned for one and the same resource.
Comment 3 Violeta Georgieva CLA 2011-05-31 03:39:24 EDT
The fix is provided in Gemini Web 2.0.0.M01 (see Bug 346431). Gemini Web 2.0.0.M01 was successfully integrated in Virgo 3.0.0.M05.
I'm keeping the bug opened because I want to provide an integration test.
Comment 4 Glyn Normington CLA 2011-06-01 10:50:55 EDT
(In reply to comment #3)
> The fix is provided in Gemini Web 2.0.0.M01 (see Bug 346431). Gemini Web
> 2.0.0.M01 was successfully integrated in Virgo 3.0.0.M05.
> I'm keeping the bug opened because I want to provide an integration test.

Closing this bug to keep the release notes for M05 accurate. Raised bug 347955 to cover the integration test.
Comment 5 Brad Chen CLA 2011-06-01 10:56:40 EDT
It's great to have this fixed. Thanks folks for the work!