Skip to content

Commit c92f53e

Browse files
committed
Improve logging, remove unnessary use of cast
1 parent 6e4ddb6 commit c92f53e

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<groupId>ch.qos.logback</groupId>
8181
<artifactId>logback-classic</artifactId>
8282
<version>0.9.26</version>
83-
<scope>test</scope>
8483
</dependency>
8584
<dependency>
8685
<groupId>log4j</groupId>

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,6 @@ private <T> Future<T> doConnect(final Request request, final AsyncHandler<T> asy
765765
return f;
766766
}
767767

768-
log.debug("\n\nNon cached Request {}\n", request);
769-
770768
if (!connectionsPool.canCacheConnection() ||
771769
(config.getMaxTotalConnections() > -1 && (maxConnections.get() + 1) > config.getMaxTotalConnections())) {
772770
throw new IOException(String.format("Too many connections %s", config.getMaxTotalConnections()));
@@ -825,6 +823,8 @@ private <T> Future<T> doConnect(final Request request, final AsyncHandler<T> asy
825823
channelFuture.addListener(c);
826824
}
827825

826+
log.debug("\n\nNon cached Request {}\n using Channel {}", request, channelFuture.getChannel());
827+
828828
if (!c.future().isCancelled() || !c.future().isDone()) {
829829
openChannels.add(channelFuture.getChannel());
830830
c.future().attachChannel(channelFuture.getChannel(), false);
@@ -1252,7 +1252,7 @@ private void abort(NettyResponseFuture<?> future, Throwable t) {
12521252
openChannels.remove(future.channel());
12531253
}
12541254

1255-
log.debug("aborting Future {}", future);
1255+
log.debug("aborting Future {}\n", future);
12561256
log.debug(t.getMessage(), t);
12571257

12581258
future.abort(t);
@@ -1293,7 +1293,7 @@ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws
12931293
exception = ex;
12941294
}
12951295

1296-
log.debug("Channel Closed: {}", e.getChannel());
1296+
log.debug("Channel Closed: {}\n with attachment {}\n", e.getChannel(), ctx.getAttachment());
12971297

12981298
if (ctx.getAttachment() instanceof AsyncCallable) {
12991299
AsyncCallable ac = (AsyncCallable) ctx.getAttachment();
@@ -1334,15 +1334,13 @@ protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future)
13341334

13351335
connectionsPool.removeAll(channel);
13361336

1337-
if (future == null && channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment() != null
1338-
&& NettyResponseFuture.class.isAssignableFrom(
1339-
channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment().getClass())) {
1337+
if (future == null) {
13401338
future = (NettyResponseFuture<?>)
13411339
channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment();
13421340
}
13431341

13441342
if (future == null || future.cannotBeReplay()) {
1345-
log.debug("Unable to replay request {} associated with future", future == null ? "" : future.getNettyRequest(), future);
1343+
log.debug("Unable to replay request {}\n associated with future {}", future == null ? "null" : future.getNettyRequest(), future);
13461344
return false;
13471345
}
13481346

@@ -1453,7 +1451,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
14531451
}
14541452

14551453
if (abortOnReadCloseException(cause) || abortOnWriteCloseException(cause)) {
1456-
log.debug("Trying to recover from dead Channel: {}", channel);
1454+
log.debug("Trying to recover request {}\n from dead Channel: {}\n", channel);
14571455
if (remotelyClosed(channel, future)) {
14581456
return;
14591457
}
@@ -1724,7 +1722,7 @@ public synchronized void run() {
17241722
}
17251723

17261724
if (this.nettyResponseFuture != null && this.nettyResponseFuture.hasExpired()) {
1727-
log.debug("Request Timeout expired for {}", this.nettyResponseFuture);
1725+
log.debug("Request Timeout expired for {}\n", this.nettyResponseFuture);
17281726

17291727
int requestTimeout = config.getRequestTimeoutInMs();
17301728
PerRequestConfig p = this.nettyResponseFuture.getRequest().getPerRequestConfig();

0 commit comments

Comments
 (0)