100
100
import java .net .InetSocketAddress ;
101
101
import java .net .MalformedURLException ;
102
102
import java .net .URI ;
103
- import java .net .URISyntaxException ;
104
103
import java .nio .channels .ClosedChannelException ;
105
104
import java .nio .channels .FileChannel ;
106
105
import java .nio .channels .WritableByteChannel ;
@@ -749,7 +748,7 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
749
748
f .setState (NettyResponseFuture .STATE .POOLED );
750
749
f .attachChannel (channel , false );
751
750
752
- log .debug ("\n Using cached Channel {}\n for request {}\n " , channel , request );
751
+ log .debug ("\n Using cached Channel {}\n for request \n {}\n " , channel , nettyRequest );
753
752
channel .getPipeline ().getContext (NettyAsyncHttpProvider .class ).setAttachment (f );
754
753
755
754
try {
@@ -824,7 +823,7 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
824
823
channelFuture .addListener (c );
825
824
}
826
825
827
- log .debug ("\n \ n Non cached Request {}\n with channel {}\n " , request , channel );
826
+ log .debug ("\n Non cached request \n {}\n \n using Channel \n {}\n " , c . future (). getNettyRequest (), channelFuture . getChannel () );
828
827
829
828
if (!c .future ().isCancelled () || !c .future ().isDone ()) {
830
829
openChannels .add (channelFuture .getChannel ());
@@ -1343,7 +1342,7 @@ protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future)
1343
1342
}
1344
1343
1345
1344
if (future == null || future .cannotBeReplay ()) {
1346
- log .debug ("Unable to replay request {}\n associated with future {}\n " , future == null ? "null" : future .getNettyRequest (), future );
1345
+ log .debug ("Unable to recover request {}\n associated with future {}\n " , future == null ? "null" : future .getNettyRequest (), future );
1347
1346
return false ;
1348
1347
}
1349
1348
@@ -1400,7 +1399,7 @@ public Object call() throws Exception {
1400
1399
}
1401
1400
1402
1401
private boolean markChannelNotReadable (final ChannelHandlerContext ctx ) {
1403
- // Catch any unexpected exception when marking the channel.
1402
+ // Catch any unexpected exception when marking the channel.
1404
1403
ctx .setAttachment (new DiscardEvent ());
1405
1404
return true ;
1406
1405
}
@@ -1432,6 +1431,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
1432
1431
Throwable cause = e .getCause ();
1433
1432
NettyResponseFuture <?> future = null ;
1434
1433
1434
+ if (log .isDebugEnabled ()) {
1435
+ log .debug ("Exception Caught: {} Attachment was {}" ,
1436
+ cause != null ? cause .getMessage () : "unavailable cause" ,
1437
+ ctx .getAttachment ());
1438
+ log .debug (cause .getMessage (), cause );
1439
+ }
1440
+
1435
1441
try {
1436
1442
1437
1443
if (cause != null && ClosedChannelException .class .isAssignableFrom (cause .getClass ())) {
@@ -1454,10 +1460,8 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
1454
1460
}
1455
1461
1456
1462
if (abortOnReadCloseException (cause ) || abortOnWriteCloseException (cause )) {
1457
- log .debug ("Trying to recover from dead Channel: {}\n request {}" , channel , future .getNettyRequest ());
1458
- if (remotelyClosed (channel , future )) {
1459
- return ;
1460
- }
1463
+ log .debug ("Trying to recover from dead Channel: {}" , channel );
1464
+ return ;
1461
1465
}
1462
1466
} else if (ctx .getAttachment () instanceof AsyncCallable ) {
1463
1467
future = ((AsyncCallable ) ctx .getAttachment ()).future ();
@@ -1473,13 +1477,6 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
1473
1477
log .error (t .getMessage (), t );
1474
1478
}
1475
1479
}
1476
-
1477
- if (log .isDebugEnabled ()) {
1478
- log .error ("Exception Caught: {} Attachment was {}" ,
1479
- cause != null ? cause .getMessage () : "unavailable cause" ,
1480
- ctx .getAttachment ());
1481
- log .error (cause .getMessage (), cause );
1482
- }
1483
1480
closeChannel (ctx );
1484
1481
ctx .sendUpstream (e );
1485
1482
}
0 commit comments