diff options
| author | Thomas Watson | 2019-11-06 19:13:06 +0000 |
|---|---|---|
| committer | Thomas Watson | 2019-11-06 19:25:33 +0000 |
| commit | ed860526600f5c43482e6eb15d7e271510c63742 (patch) | |
| tree | d69798b98253e77e54be41eb7e892c2bec45a304 | |
| parent | fb6258ed257d3b1263c7c7e340b44a5102b52b79 (diff) | |
| download | rt.equinox.framework-ed860526600f5c43482e6eb15d7e271510c63742.tar.gz rt.equinox.framework-ed860526600f5c43482e6eb15d7e271510c63742.tar.xz rt.equinox.framework-ed860526600f5c43482e6eb15d7e271510c63742.zip | |
Bug 552573 - remove leading '/' before calling getEntry
Change-Id: I7d62eb7cbc0b09a8c0227c83c91bf5bc5bf28bdf
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
2 files changed, 19 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java index 56dd9df1f..fa977dd02 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java @@ -563,11 +563,24 @@ public class ConnectTests extends AbstractBundleTests { assertEquals("Wrong number of wiring entry URLs.", entries.size(), wiringEntryUrls.size()); assertTrue("Wrong wiring entry URLs: " + wiringEntryUrls, entries.containsAll(wiringEntryUrls)); - String txtPath = "org/eclipse/osgi/tests/bundles/resources/" + id + ".txt"; + String txtPathDir = "org/eclipse/osgi/tests/bundles/resources/"; + String txtPath = txtPathDir + id + ".txt"; Optional<ConnectEntry> txtConnectEntry = m.getContent().getEntry(txtPath); assertTrue("Could not find text entry.", txtConnectEntry.isPresent()); + checkEntry(txtConnectEntry.get(), b.getEntry(txtPath), id); checkEntry(txtConnectEntry.get(), b.getResource(txtPath), id); + Enumeration<URL> found = b.findEntries(txtPathDir, "*.txt", false); + checkEntry(txtConnectEntry.get(), found.nextElement(), id); + assertFalse("More entries found.", found.hasMoreElements()); + + // now try with leading '/' + String slashTxtPath = '/' + txtPath; + checkEntry(txtConnectEntry.get(), b.getEntry(slashTxtPath), id); + checkEntry(txtConnectEntry.get(), b.getResource(slashTxtPath), id); + found = b.findEntries('/' + txtPathDir, "*.txt", false); + checkEntry(txtConnectEntry.get(), found.nextElement(), id); + assertFalse("More entries found.", found.hasMoreElements()); } } catch (Throwable t) { sneakyThrow(t); @@ -619,7 +632,8 @@ public class ConnectTests extends AbstractBundleTests { } void checkEntry(ConnectEntry expected, URL actual, Integer id) throws IOException { - assertEquals("Wring path.", expected.getName(), actual.getPath().substring(1)); + assertNotNull("No entry found.", actual); + assertEquals("Wrong path.", expected.getName(), actual.getPath().substring(1)); URLConnection connection = actual.openConnection(); assertEquals("Wrong last modified.", expected.getLastModified(), connection.getLastModified()); assertEquals("Wrong content length.", expected.getContentLength(), connection.getContentLengthLong()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectBundleFile.java index 846f7173c..a40c235b2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectBundleFile.java @@ -105,6 +105,9 @@ public class ConnectBundleFile extends CloseableBundleFile<ConnectEntry> { @Override protected BundleEntry findEntry(String path) { + if (path.length() > 0 && path.charAt(0) == '/') { + path = path.substring(1); + } return content.getEntry(path).map(ConnectBundleEntry::new).orElse(null); } |
