Skip to content

Commit 1a551e3

Browse files
author
Stephane Landelle
committed
Backport c9331b0
1 parent 739c3a6 commit 1a551e3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/java/com/ning/http/client/AsyncHttpClient.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.Closeable;
2929
import java.io.IOException;
3030
import java.io.InputStream;
31+
import java.lang.reflect.InvocationTargetException;
3132
import java.util.Collection;
3233
import java.util.Map;
3334
import java.util.concurrent.ExecutorService;
@@ -576,6 +577,16 @@ private final static AsyncHttpProvider loadDefaultProvider(String className, Asy
576577
new Class[]{AsyncHttpClientConfig.class}).newInstance(new Object[]{config});
577578
} catch (Throwable t) {
578579

580+
if (t instanceof InvocationTargetException) {
581+
final InvocationTargetException ite = (InvocationTargetException) t;
582+
if (logger.isErrorEnabled()) {
583+
logger.error(
584+
"Unable to instantiate provider {}. Trying other providers.",
585+
className);
586+
logger.error(ite.getCause().toString(), ite.getCause());
587+
}
588+
}
589+
579590
// Let's try with another classloader
580591
try {
581592
Class<AsyncHttpProvider> providerClass = (Class<AsyncHttpProvider>)

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
240240
secureBootstrap = new ClientBootstrap(socketChannelFactory);
241241
webSocketBootstrap = new ClientBootstrap(socketChannelFactory);
242242
secureWebSocketBootstrap = new ClientBootstrap(socketChannelFactory);
243-
configureNetty();
244-
245243
this.config = config;
246244

245+
configureNetty();
246+
247247
// This is dangerous as we can't catch a wrong typed ConnectionsPool
248248
ConnectionsPool<String, Channel> cp = (ConnectionsPool<String, Channel>) config.getConnectionsPool();
249249
if (cp == null && config.getAllowPoolingConnection()) {

0 commit comments

Comments
 (0)