Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345743 - BundleWiring.listResources does not work properly for directoy classpath entries
Summary: BundleWiring.listResources does not work properly for directoy classpath entries
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 RC2   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-13 11:05 EDT by Thomas Watson CLA
Modified: 2011-05-13 16:19 EDT (History)
2 users (show)

See Also:
hargrave: review+
jwross: review+


Attachments
Patch + test (6.06 KB, patch)
2011-05-13 11:30 EDT, Thomas Watson CLA
no flags Details | Diff
updated patch and tests (6.63 KB, patch)
2011-05-13 13:47 EDT, Thomas Watson CLA
no flags Details | Diff
updated patch and tests (5.64 KB, patch)
2011-05-13 14:18 EDT, Thomas Watson CLA
no flags Details | Diff
updated patch and tests (5.93 KB, patch)
2011-05-13 14:19 EDT, Thomas Watson CLA
no flags Details | Diff
updated patch and tests (6.67 KB, patch)
2011-05-13 14:32 EDT, Thomas Watson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.