Skip to content

Commit 74b6b0f

Browse files
author
Stephane Landelle
committed
Prevent file description leak on ClosedChannelException, close AsyncHttpClient#288
1 parent 32c9945 commit 74b6b0f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,16 @@ protected final <T> void writeRequest(final Channel channel,
530530
final FileRegion region = new OptimizedFileRegion(raf, 0, fileLength);
531531
writeFuture = channel.write(region);
532532
}
533-
writeFuture.addListener(new ProgressListener(false, future.getAsyncHandler(), future));
533+
writeFuture.addListener(new ProgressListener(false, future.getAsyncHandler(), future) {
534+
public void operationComplete(ChannelFuture cf) {
535+
try {
536+
raf.close();
537+
} catch (IOException e) {
538+
log.warn("Failed to close request body: {}", e.getMessage(), e);
539+
}
540+
super.operationComplete(cf);
541+
}
542+
});
534543
} catch (IOException ex) {
535544
if (raf != null) {
536545
try {

0 commit comments

Comments
 (0)