Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java10
2 files changed, 13 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
index 008347e46..791f4dc66 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
@@ -188,6 +188,7 @@ public class BasicLocationTests extends CoreTest {
doTestLocateDataArea(location, dataAreaPrefix, "test/multiple/paths");
doTestLocateDataArea(location, dataAreaPrefix, "test/multiple/../paths");
doTestLocateDataArea(location, dataAreaPrefix, "test\\multiple\\paths");
+ doTestLocateDataArea(location, dataAreaPrefix, "/test/begin/slash");
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/" + getName());
Location createdLocation = location.createLocation(null, null, false);
@@ -201,6 +202,7 @@ public class BasicLocationTests extends CoreTest {
doTestLocateDataArea(createdLocation, dataAreaPrefix, "test/multiple/paths");
doTestLocateDataArea(createdLocation, dataAreaPrefix, "test/multiple/../paths");
doTestLocateDataArea(location, dataAreaPrefix, "test\\multiple\\paths");
+ doTestLocateDataArea(location, dataAreaPrefix, "/test/begin/slash");
createdLocation = location.createLocation(null, null, false);
try {
@@ -222,6 +224,9 @@ public class BasicLocationTests extends CoreTest {
assertNotNull("Data area is null.", dataArea);
namespace = namespace.replace('\\', '/');
+ if (namespace.startsWith("/")) {
+ namespace = namespace.substring(1);
+ }
assertTrue("Data area is not the expected value: " + dataArea.toExternalForm(), dataArea.toExternalForm().endsWith(dataAreaPrefix + namespace));
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java
index 68f084c46..c9256a0eb 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/location/BasicLocation.java
@@ -45,7 +45,13 @@ public class BasicLocation implements Location {
this.property = property;
this.defaultValue = defaultValue;
this.isReadOnly = isReadOnly;
- this.dataAreaPrefix = dataAreaPrefix == null ? "" : dataAreaPrefix; //$NON-NLS-1$
+ // make sure the prefix ends with '/' if it is not empty/null
+ String tempDataAreaPrefix = dataAreaPrefix == null ? "" : dataAreaPrefix; //$NON-NLS-1$
+ tempDataAreaPrefix = tempDataAreaPrefix.replace('\\', '/');
+ if (tempDataAreaPrefix.length() > 0 && tempDataAreaPrefix.charAt(tempDataAreaPrefix.length() - 1) != '/') {
+ tempDataAreaPrefix += '/';
+ }
+ this.dataAreaPrefix = tempDataAreaPrefix;
this.environmentInfo = environmentInfo;
this.debug = environmentInfo.getDebug().DEBUG_LOCATION;
}
@@ -223,7 +229,7 @@ public class BasicLocation implements Location {
prefix += '/';
filename = filename.replace('\\', '/');
if (filename.length() > 0 && filename.charAt(0) == '/')
- filename.substring(1);
+ filename = filename.substring(1);
String spec = prefix + dataAreaPrefix + filename;
boolean trailingSlash = spec.length() > 0 && spec.charAt(spec.length() - 1) == '/';
return LocationHelper.buildURL(spec, trailingSlash);

Back to the top