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

Bug 345743

Summary: BundleWiring.listResources does not work properly for directoy classpath entries
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: FrameworkAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hargrave, jwross
Version: 3.7Flags: hargrave: review+
jwross: review+
Target Milestone: 3.7 RC2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch + test
none
updated patch and tests
none
updated patch and tests
none
updated patch and tests
none
updated patch and tests none

Description Thomas Watson CLA 2011-05-13 11:05:38 EDT
When a bundle has a nested directory as a Bundle-ClassPath entry the BundleWiring.listResources method does not find any resources from the directory class path entry.  This will be very problematic for scenarios that want to do classpath scanning on a web application bundle.  In this case the Bundle-ClassPath will have the following:

Bundle-ClassPath: WEB-INF/classes/

This is because the NestedDirBundleFile.getEntryPaths method does nothing:

	public Enumeration<String> getEntryPaths(String path) {
		// getEntryPaths is only valid if this is a root bundle file.
		return null;
	}

The comment is obviously no longer correct ;-)  This method gets used by BundleWiring.listResources now.
Comment 1 Thomas Watson CLA 2011-05-13 11:30:30 EDT
Created attachment 195601 [details]
Patch + test

This patch implements the org.eclipse.osgi.baseadaptor.bundlefile.NestedDirBundleFile.getEntryPaths(String) method properly.
Comment 2 Thomas Watson CLA 2011-05-13 11:31:47 EDT
This bug is important to fix.  One of the important usecases of BundleWiring.listResources method is to enable the classpath scanning of Web Application Bundles.
Comment 3 Thomas Watson CLA 2011-05-13 11:32:48 EDT
John and BJ, please review for RC2.
Comment 4 BJ Hargrave CLA 2011-05-13 12:50:10 EDT
I would make new prependNestedDir method private access. Allows the compiler to inline it.
Comment 5 John Ross CLA 2011-05-13 13:46:17 EDT
(In reply to comment #4)
> I would make new prependNestedDir method private access. Allows the compiler to
> inline it.

Otherwise, looks okay to me.
Comment 6 Thomas Watson CLA 2011-05-13 13:47:42 EDT
Created attachment 195610 [details]
updated patch and tests

Updated patch to make prependNestedDir private.  I also made the cp and baseBundleFile fields final privates.
Comment 7 John Ross CLA 2011-05-13 13:59:28 EDT
(In reply to comment #6)
> Created attachment 195610 [details]
> updated patch and tests
> Updated patch to make prependNestedDir private.  I also made the cp and
> baseBundleFile fields final privates.

What's this stuff for in the patch?

Index: bundles_src/test2/stuff/data/resource2
===================================================================
RCS file: bundles_src/test2/stuff/data/resource2
diff -N bundles_src/test2/stuff/data/resource2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ bundles_src/test2/stuff/data/resource2	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+stuff classpath test2
\ No newline at end of file
Index: bundles_src/test2/stuff/resource2
===================================================================
RCS file: bundles_src/test2/stuff/resource2
diff -N bundles_src/test2/stuff/resource2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ bundles_src/test2/stuff/resource2	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+stuff classpath test2
\ No newline at end of file
Comment 8 Thomas Watson CLA 2011-05-13 14:18:12 EDT
Created attachment 195617 [details]
updated patch and tests

(In reply to comment #7)
> What's this stuff for in the patch?
> 
Just junk from another test I was writing.  It is not in this updated patch.

This patch avoids the synthetic access to the private final cp field.
Comment 9 Thomas Watson CLA 2011-05-13 14:19:31 EDT
Created attachment 195618 [details]
updated patch and tests

Sigh, I am not having good luck at getting the right patch attached.  Lets try that again.
Comment 10 Thomas Watson CLA 2011-05-13 14:32:08 EDT
Created attachment 195622 [details]
updated patch and tests

(In reply to comment #7)
> What's this stuff for in the patch?
> 

You know what.  This stuff is needed in the patch.  That is the resource I am searching for in the test!
Comment 11 Thomas Watson CLA 2011-05-13 16:19:48 EDT
patch released.