Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-10-06 16:04:18 +0000
committerThomas Watson2014-10-06 16:04:18 +0000
commit8d121ce379bc1b77b4910276604760adb10f3bd8 (patch)
tree6e9de18959ac93e648cf8a9802b3e3f4dbf54704 /bundles
parente8c1e08320108be920c0198626ea0bc509221ee3 (diff)
downloadrt.equinox.framework-8d121ce379bc1b77b4910276604760adb10f3bd8.tar.gz
rt.equinox.framework-8d121ce379bc1b77b4910276604760adb10f3bd8.tar.xz
rt.equinox.framework-8d121ce379bc1b77b4910276604760adb10f3bd8.zip
Bug 439134 - BasicLocation.getDataArea uses substring but discards theI20141008-1300I20141007-1500I20141007-0800
results Change-Id: I585ee53f21ae00189995d0ad0971852b2cf9a67e Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
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