You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pa...@apache.org on 2020/01/27 16:31:47 UTC
svn commit: r1873222 -
/felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java
Author: pauls
Date: Mon Jan 27 16:31:47 2020
New Revision: 1873222
URL: http://svn.apache.org/viewvc?rev=1873222&view=rev
Log:
Try to load handlers for buildin urlhandlers from existing factory first
Modified:
felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java
Modified: felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java?rev=1873222&r1=1873221&r2=1873222&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java (original)
+++ felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/URLHandlers.java Mon Jan 27 16:31:47 2020
@@ -124,16 +124,27 @@ class URLHandlers implements URLStreamHa
{
try
{
- URLStreamHandler handler = getBuiltInStreamHandler(protocol, factory);
- if (handler != null)
- {
- URL url = new URL(protocol, null, -1, "", handler);
- addToCache(m_protocolToURL, protocol, url);
- }
+ // Try to get it directly from the URL class to if possible
+ Method getURLStreamHandler = m_secureAction.getDeclaredMethod(URL.class,"getURLStreamHandler", new Class[]{String.class});
+ URLStreamHandler handler = (URLStreamHandler) m_secureAction.invoke(getURLStreamHandler, null, new Object[]{protocol});
+ addToCache(m_builtIn, protocol, handler);
}
catch (Throwable ex)
{
- // Ignore, this is a best effort (maybe log it or something).
+ // Ignore, this is a best effort
+ try
+ {
+ URLStreamHandler handler = getBuiltInStreamHandler(protocol, factory);
+ if (handler != null)
+ {
+ URL url = new URL(protocol, null, -1, "", handler);
+ addToCache(m_protocolToURL, protocol, url);
+ }
+ }
+ catch (Throwable ex2)
+ {
+ // Ignore, this is a best effort (maybe log it or something).
+ }
}
}
@@ -165,14 +176,7 @@ class URLHandlers implements URLStreamHa
init("ftp", currentFactory);
init("http", currentFactory);
init("https", currentFactory);
- try
- {
- getBuiltInStreamHandler("jar", currentFactory);
- }
- catch (Throwable ex)
- {
- // Ignore, this is a best effort (maybe log it or something)
- }
+
// Try to preload the jrt handler as we need it from the jvm on java > 8
if (getFromCache(m_builtIn, "jrt") == null)
@@ -197,6 +201,30 @@ class URLHandlers implements URLStreamHa
}
}
}
+
+ // Try to preload the jrt handler as we need it from the jvm on java > 8
+ if (getFromCache(m_builtIn, "jar") == null)
+ {
+ try
+ {
+ // Try to get it directly from the URL class to if possible
+ Method getURLStreamHandler = m_secureAction.getDeclaredMethod(URL.class,"getURLStreamHandler", new Class[]{String.class});
+ URLStreamHandler handler = (URLStreamHandler) m_secureAction.invoke(getURLStreamHandler, null, new Object[]{"jar"});
+ addToCache(m_builtIn, "jar", handler);
+ }
+ catch (Throwable ex)
+ {
+ // Ignore, this is a best effort
+ try
+ {
+ getBuiltInStreamHandler("jar", currentFactory);
+ }
+ catch (Throwable ex2)
+ {
+ // Ignore, this is a best effort (maybe log it or something)
+ }
+ }
+ }
if (currentFactory != null)
{