diff options
author | Thomas Watson | 2018-06-12 16:13:07 +0000 |
---|---|---|
committer | Thomas Watson | 2018-06-13 19:21:39 +0000 |
commit | c4c90b1c75780b2262b80534035c593ba8dd8f0e (patch) | |
tree | 45ca08c459a1e25d2749ad1f1c0f194a9c6965b8 /bundles/org.eclipse.osgi | |
parent | 2c660df89f34884d8fb27eebbaa12df68cc3f2e8 (diff) | |
download | rt.equinox.framework-c4c90b1c75780b2262b80534035c593ba8dd8f0e.tar.gz rt.equinox.framework-c4c90b1c75780b2262b80534035c593ba8dd8f0e.tar.xz rt.equinox.framework-c4c90b1c75780b2262b80534035c593ba8dd8f0e.zip |
Bug 533867 - Fix when installing locations with # or ?I20180615-0655I20180615-0300I20180614-2045I20180614-2000
Change-Id: I54e44d710c232ddbc96faac06a8b6123c670efce
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi')
3 files changed, 22 insertions, 17 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index 578581f19..6e097c601 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -1013,10 +1013,7 @@ public class Storage { File outFile = null; try { if (in instanceof ReferenceInputStream) { - URL reference = ((ReferenceInputStream) in).getReference(); - if (!"file".equals(reference.getProtocol())) //$NON-NLS-1$ - throw new BundleException(NLS.bind(Msg.ADAPTOR_URL_CREATE_EXCEPTION, reference)); - return new File(reference.getPath()); + return ((ReferenceInputStream) in).getReference(); } outFile = File.createTempFile(BUNDLE_FILE_NAME, ".tmp", childRoot); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceInputStream.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceInputStream.java index fdd95770b..ef2026e47 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceInputStream.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceInputStream.java @@ -11,18 +11,18 @@ package org.eclipse.osgi.storage.url.reference; +import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.URL; /** - * InputStream subclass which provides a reference (via URL) to the data + * InputStream subclass which provides a reference (via File) to the data * rather than allowing the input stream to be directly read. */ public class ReferenceInputStream extends InputStream { - protected URL reference; + private final File reference; - public ReferenceInputStream(URL reference) { + public ReferenceInputStream(File reference) { this.reference = reference; } @@ -32,7 +32,7 @@ public class ReferenceInputStream extends InputStream { throw new IOException(); } - public URL getReference() { + public File getReference() { return reference; } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java index c776c8b0b..b1819841d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java @@ -11,11 +11,17 @@ package org.eclipse.osgi.storage.url.reference; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import org.eclipse.osgi.framework.util.FilePath; import org.eclipse.osgi.internal.location.LocationHelper; +import org.eclipse.osgi.internal.messages.Msg; +import org.eclipse.osgi.util.NLS; /** * URLConnection for the reference protocol. @@ -23,23 +29,25 @@ import org.eclipse.osgi.internal.location.LocationHelper; public class ReferenceURLConnection extends URLConnection { private final String installPath; - private URL reference; + private volatile File reference; protected ReferenceURLConnection(URL url, String installPath) { super(url); this.installPath = installPath; } - @SuppressWarnings("deprecation") public synchronized void connect() throws IOException { if (!connected) { // TODO assumes that reference URLs are always based on file: URLs. // There are not solid usecases to the contrary. Yet. - // Construct the ref URL carefully so as to preserve UNC paths etc. - String path = url.getPath().substring(5); + // Construct the ref File carefully so as to preserve UNC paths etc. + String path = url.getPath(); + if (!path.startsWith("file:")) { //$NON-NLS-1$ + throw new IOException(NLS.bind(Msg.ADAPTOR_URL_CREATE_EXCEPTION, path)); + } + path = url.getPath().substring(5); File file = new File(path); - URL ref; if (!file.isAbsolute()) { if (installPath != null) file = makeAbsolute(installPath, file); @@ -47,10 +55,10 @@ public class ReferenceURLConnection extends URLConnection { file = LocationHelper.decodePath(file); - ref = file.toURL(); checkRead(file); - reference = ref; + reference = file; + connected = true; } } |