Skip to content

Commit 6496b00

Browse files
committed
Perform WriteListener#abortOnThrowable whatever the channel state, close AsyncHttpClient#1488
Motivation For some reason lost in time, abortOnThrowable is only performed if the channel is not a new one. I have no idea why and it swallow exceptions, so we get timeouts instead of actual exception. Modification: Drop this test and always perform abortOnThrowable, whatever the channel state. Result: Proper exception reported
1 parent 482ad4b commit 6496b00

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

client/src/main/java/org/asynchttpclient/netty/request/WriteListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.asynchttpclient.handler.ProgressAsyncHandler;
2121
import org.asynchttpclient.netty.NettyResponseFuture;
22-
import org.asynchttpclient.netty.channel.ChannelState;
2322
import org.asynchttpclient.netty.channel.Channels;
2423
import org.asynchttpclient.netty.future.StackTraceInspector;
2524
import org.slf4j.Logger;
@@ -39,7 +38,7 @@ public WriteListener(NettyResponseFuture<?> future, boolean notifyHeaders) {
3938
}
4039

4140
private boolean abortOnThrowable(Channel channel, Throwable cause) {
42-
if (cause != null && future.getChannelState() != ChannelState.NEW) {
41+
if (cause != null) {
4342
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) {
4443
LOGGER.debug(cause.getMessage(), cause);
4544
Channels.silentlyCloseChannel(channel);

client/src/test/java/org/asynchttpclient/request/body/PutFileTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class PutFileTest extends AbstractBasicTest {
3535

3636
private void put(int fileSize) throws Exception {
3737
File file = createTempFile(fileSize);
38-
int timeout = (int) file.length() / 1000;
39-
try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(timeout))) {
38+
try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(2000))) {
4039
Response response = client.preparePut(getTargetUrl()).setBody(file).execute().get();
4140
assertEquals(response.getStatusCode(), 200);
4241
}

0 commit comments

Comments
 (0)