Skip to content

Commit f4768d0

Browse files
committed
Improve logging flow when replaying request. No functional change
1 parent 94f861f commit f4768d0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private Channel lookupInCache(URI uri) {
276276
final Channel channel = connectionsPool.poll(AsyncHttpProviderUtils.getBaseUrl(uri));
277277

278278
if (channel != null) {
279-
log.debug("Using cached Channel {} for uri {}", channel, uri);
279+
log.debug("Using cached Channel {}\n for uri {}\n", channel, uri);
280280

281281
try {
282282
// Always make sure the channel who got cached support the proper protocol. It could
@@ -748,7 +748,7 @@ private <T> Future<T> doConnect(final Request request, final AsyncHandler<T> asy
748748
f.setState(NettyResponseFuture.STATE.POOLED);
749749
f.attachChannel(channel, false);
750750

751-
log.debug("\n\nCached Request {}\n", channel);
751+
log.debug("\nUsing cached Channel {}\n for request {}\n", channel, request);
752752
channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(f);
753753

754754
try {
@@ -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 with channel {}\n", request, channel);
827+
828828
if (!c.future().isCancelled() || !c.future().isDone()) {
829829
openChannels.add(channelFuture.getChannel());
830830
c.future().attachChannel(channelFuture.getChannel(), false);
@@ -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: {} with attachment {}", e.getChannel(), ctx.getAttachment());
12971297

12981298
if (ctx.getAttachment() instanceof AsyncCallable) {
12991299
AsyncCallable ac = (AsyncCallable) ctx.getAttachment();
@@ -1342,21 +1342,21 @@ protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future)
13421342
}
13431343

13441344
if (future == null || future.cannotBeReplay()) {
1345-
log.debug("Unable to replay request {} associated with future", future == null ? "" : future.getNettyRequest(), future);
1345+
log.debug("Unable to replay request {}\n associated with future {}\n", future == null ? "null" : future.getNettyRequest(), future);
13461346
return false;
13471347
}
13481348

13491349
future.setState(NettyResponseFuture.STATE.RECONNECTED);
13501350

1351-
log.debug("Trying to recover request {}", future.getNettyRequest());
1351+
log.debug("Trying to recover request {}\n", future.getNettyRequest());
13521352

13531353
try {
13541354
nextRequest(future.getRequest(), future);
13551355
return true;
13561356
} catch (IOException iox) {
13571357
future.setState(NettyResponseFuture.STATE.CLOSED);
13581358
future.abort(iox);
1359-
log.error("Remotely Closed", iox);
1359+
log.error("Remotely Closed, unable to recover", iox);
13601360
}
13611361
return false;
13621362
}
@@ -1453,7 +1453,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
14531453
}
14541454

14551455
if (abortOnReadCloseException(cause) || abortOnWriteCloseException(cause)) {
1456-
log.debug("Trying to recover from dead Channel: {}", channel);
1456+
log.debug("Trying to recover from dead Channel: {}\n request {}", channel, future.getNettyRequest());
14571457
if (remotelyClosed(channel, future)) {
14581458
return;
14591459
}
@@ -1724,7 +1724,7 @@ public synchronized void run() {
17241724
}
17251725

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

17291729
int requestTimeout = config.getRequestTimeoutInMs();
17301730
PerRequestConfig p = this.nettyResponseFuture.getRequest().getPerRequestConfig();

0 commit comments

Comments
 (0)