Closed al-popa closed 1 month ago
Can you reproduce this issue with latest release or current 4.31 RC2 of the Eclipse SDK?
Proposed change:
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
index 9139125..1387dbf 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
@@ -217,7 +217,8 @@
connect(true); // connect and force caching if necessary
URL u = connection.getURL();
String up = u.getProtocol();
- if (!up.equals(PlatformURLHandler.FILE) && !up.equals(PlatformURLHandler.JAR) && !up.startsWith(PlatformURLHandler.BUNDLE))
+ if (!up.equals(PlatformURLHandler.FILE) && !up.equals(PlatformURLHandler.JAR) //
+ && !up.startsWith(PlatformURLHandler.BUNDLE) && !up.startsWith(PlatformURLHandler.PROTOCOL))
throw new IOException(NLS.bind(CommonMessages.url_noaccess, up));
return u;
}
Proposed change:
Cool. Please make a pull request for it to facilitate review.
I could not reproduce the error with a test like this:
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/EquinoxBundleAdaptTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/EquinoxBundleAdaptTests.java
index 9aba6c3..0a76b6d 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/EquinoxBundleAdaptTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/EquinoxBundleAdaptTests.java
@@ -17,6 +17,7 @@
import static org.junit.Assert.assertNotNull;
import java.io.File;
+import java.net.URI;
import java.net.URL;
import java.security.Permission;
import java.security.ProtectionDomain;
@@ -74,4 +75,12 @@
assertEquals(new File(testBundleRoot, "bundle_tests"), file.getParentFile());
assertEquals("test", file.getName().replace(".jar", ""));
}
+
+ @Test
+ public void testGh635() throws Exception {
+ URL testBundleURL = URI
+ .create("platform:/plugin/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/debug.gif").toURL();
+ URL fileURL = FileLocator.toFileURL(testBundleURL);
+ org.junit.Assert.assertTrue(fileURL.toString(), new File(fileURL.toURI()).exists());
+ }
}
Affected version:
Eclipse SDK Version: 2023-09 (4.29) Build id: I20230903-1000 OS: Windows 10, v.10.0, x86_64 / win32 Java vendor: Eclipse Adoptium Java runtime version: 17.0.9+9 Java version: 17.0.9
It turns out, the URL using platform:/ protocol was invalid. It resolved to the path containing 2 tokens of protocol, something like:
platform:/<project>/platform:/<project>/<path>.
I am not sure how this path was resolved, but the issue cannot be reproduced in JUnit as @Jörg Kubitz shown. The path issue was solved downstream.
Close this issue.
The platform:/ URL protocol is defined in org.eclipse.core.internal.boot.PlatformURLHandler.PROTOCOL. However, in org.eclipse.core.internal.boot.PlatformURLConnection.getURLAsLocal() this protocol is not checked when performing sanity check. This leads to error log being logged about unknown protocol. This method is used in a public API method org.eclipse.core.runtime.FileLocator.toFileURL(URL). However, the menu icons using this protocol are successfully found, loaded and shown. The error log is misleading and probably wrong.
The exception stacktrace is: