Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06C7518C03 for ; Thu, 3 Mar 2016 18:10:19 +0000 (UTC) Received: (qmail 54817 invoked by uid 500); 3 Mar 2016 18:10:18 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 54718 invoked by uid 500); 3 Mar 2016 18:10:18 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 54507 invoked by uid 99); 3 Mar 2016 18:10:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 18:10:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 777522C1F75 for ; Thu, 3 Mar 2016 18:10:18 +0000 (UTC) Date: Thu, 3 Mar 2016 18:10:18 +0000 (UTC) From: "Charles Allen (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (HTTPCLIENT-1727) org.apache.http.impl.client.AbstractHttpClient#createClientConnectionManager Does not account for context class loader MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Charles Allen resolved HTTPCLIENT-1727. --------------------------------------- Resolution: Fixed > org.apache.http.impl.client.AbstractHttpClient#createClientConnectionManager Does not account for context class loader > ---------------------------------------------------------------------------------------------------------------------- > > Key: HTTPCLIENT-1727 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1727 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.4.1, 4.5, 4.5.1, 4.5.2 > Reporter: Charles Allen > Fix For: 4.5.3 > > > org.apache.http.impl.client.AbstractHttpClient#createClientConnectionManager Does not account for context class loader. > This means that only ClientConnectionManager factories visible in AbstractHttpClient's classloader are loadable by AbstractHttpClient > An example of a failure here is if httpclient and jets3t are loaded in different classloaders, where jets3t is in a child classloader of httpclient's classloader. In such a case httpclient classes will be visible to jets3t, but jets3t's classes will not be visible to httpclient so org.jets3t.service.utils.RestUtils$ConnManagerFactory will not be found. > The proposed fix against the 4.5.x branch is as follows: > {code} > diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java > index 18a42d7..34c6e0f 100644 > --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java > +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java > @@ -327,9 +327,15 @@ public abstract class AbstractHttpClient extends CloseableHttpClient { > final String className = (String) params.getParameter( > ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME); > + final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); > if (className != null) { > try { > - final Class clazz = Class.forName(className); > + final Class clazz; > + if(contextLoader != null) { > + clazz = Class.forName(className, true, contextLoader); > + } else { > + clazz = Class.forName(className); > + } > factory = (ClientConnectionManagerFactory) clazz.newInstance(); > } catch (final ClassNotFoundException ex) { > throw new IllegalStateException("Invalid class name: " + className); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org