@@ -317,14 +317,9 @@ protected final <T> void writeRequest(final Channel channel,
317
317
try {
318
318
/**
319
319
* If the channel is dead because it was pooled and the remote server decided to close it,
320
- * we need to try to recover in order to prevent failing a valid request .
320
+ * we just let it go and the closeChannel do it's work .
321
321
*/
322
322
if (!channel .isOpen () || !channel .isConnected ()) {
323
- if (!remotelyClosed (channel , future )) {
324
- abort (future , new ConnectException ());
325
- } else {
326
- log .debug ("Request {} has been recovered" , nettyRequest );
327
- }
328
323
return ;
329
324
}
330
325
@@ -366,12 +361,12 @@ protected final <T> void writeRequest(final Channel channel,
366
361
channel .write (nettyRequest ).addListener (new ProgressListener (true , future .getAsyncHandler (), future ));
367
362
} catch (Throwable cause ) {
368
363
log .debug (cause .getMessage (), cause );
369
-
370
- if (future .provider ().remotelyClosed (channel , future )) {
371
- return ;
372
- } else {
373
- future .abort (cause );
364
+ try {
365
+ channel .close ();
366
+ } catch (RuntimeException ex ) {
367
+ log .debug (ex .getMessage (), ex );
374
368
}
369
+ return ;
375
370
}
376
371
}
377
372
@@ -426,10 +421,11 @@ public void operationComplete(ChannelFuture cf) {
426
421
}
427
422
}
428
423
} catch (Throwable ioe ) {
429
- if (future .provider ().remotelyClosed (channel , future )) {
430
- return ;
424
+ try {
425
+ channel .close ();
426
+ } catch (RuntimeException ex ) {
427
+ log .debug (ex .getMessage (), ex );
431
428
}
432
- abort (future , ioe );
433
429
}
434
430
435
431
try {
@@ -866,7 +862,7 @@ private void finishChannel(final ChannelHandlerContext ctx) {
866
862
try {
867
863
ctx .getChannel ().close ();
868
864
} catch (Throwable t ) {
869
- log .error ( "error closing a connection" , t );
865
+ log .debug ( "Error closing a connection" , t );
870
866
}
871
867
openChannels .remove (ctx .getChannel ());
872
868
}
@@ -1604,11 +1600,12 @@ public void operationComplete(ChannelFuture cf) {
1604
1600
1605
1601
if (IllegalStateException .class .isAssignableFrom (cause .getClass ())) {
1606
1602
log .debug (cause .getMessage (), cause );
1607
- if ( future . provider (). remotelyClosed ( cf . getChannel (), future )) {
1608
- return ;
1609
- } else {
1610
- future . abort ( cause );
1603
+ try {
1604
+ cf . getChannel (). close () ;
1605
+ } catch ( RuntimeException ex ) {
1606
+ log . debug ( ex . getMessage (), ex );
1611
1607
}
1608
+ return ;
1612
1609
}
1613
1610
1614
1611
if (ClosedChannelException .class .isAssignableFrom (cause .getClass ())
@@ -1619,11 +1616,12 @@ public void operationComplete(ChannelFuture cf) {
1619
1616
log .debug (cf .getCause () == null ? "" : cf .getCause ().getMessage (), cf .getCause ());
1620
1617
}
1621
1618
1622
- if ( future . provider (). remotelyClosed ( cf . getChannel (), future )) {
1623
- return ;
1624
- } else {
1625
- future . abort ( cause );
1619
+ try {
1620
+ cf . getChannel (). close () ;
1621
+ } catch ( RuntimeException ex ) {
1622
+ log . debug ( ex . getMessage (), ex );
1626
1623
}
1624
+ return ;
1627
1625
} else {
1628
1626
future .abort (cause );
1629
1627
}
0 commit comments