Issue #5320 - use HttpClient classloader to load jetty-websocket-httpclient.xml
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
6cd70ce136
commit
1b07c846c6
|
@ -24,11 +24,6 @@
|
|||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-xml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.jetty.client.HttpClient;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
|
@ -42,25 +41,19 @@ class XmlBasedHttpClientProvider
|
|||
if (resource == null)
|
||||
return null;
|
||||
|
||||
// Try to load a HttpClient from a jetty-websocket-httpclient.xml configuration file.
|
||||
// If WebAppClassLoader run with server class access, otherwise run normally.
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return WebAppClassLoader.runWithServerClassAccess(() -> newHttpClient(resource));
|
||||
}
|
||||
catch (NoClassDefFoundError | ClassNotFoundException e)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Could not use WebAppClassLoader to run with Server class access", e);
|
||||
return newHttpClient(resource);
|
||||
}
|
||||
Thread.currentThread().setContextClassLoader(HttpClient.class.getClassLoader());
|
||||
return newHttpClient(resource);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
LOG.warn("Failure to load HttpClient from XML", t);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader(contextClassLoader);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue