Skip to content

Commit 37adafe

Browse files
author
Rachid Ben Moussa
committed
Changed future.channel() to channel which is guarded to be non null
1 parent 2222b03 commit 37adafe

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ private void scheduleReadTimeout(NettyResponseFuture<?> nettyResponseFuture) {
464464
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) {
465465

466466
if (channel != null) {
467-
Object attribute = Channels.getAttribute(future.channel());
467+
Object attribute = Channels.getAttribute(channel);
468468
if (attribute instanceof StreamedResponsePublisher) {
469469
((StreamedResponsePublisher) attribute).setError(t);
470470
}

Diff for: client/src/test/java/org/asynchttpclient/netty/NettyConnectionResetByPeerTest.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ public void testAsyncHttpClientConnectionResetByPeer() throws InterruptedExcepti
4141
.build();
4242
new DefaultAsyncHttpClient(config).executeRequest(
4343
new RequestBuilder("GET").setUrl(resettingServerAddress)
44-
).get();
44+
)
45+
.get();
4546
} catch (ExecutionException e) {
4647
Throwable ex = e.getCause();
47-
assertThat(ex, is(not(instanceOf(TimeoutException.class))));
4848
assertThat(ex, is(instanceOf(IOException.class)));
49-
// assertTrue(ex.getMessage().equalsIgnoreCase("Connection reset by peer"));
5049
}
5150
}
5251

@@ -79,7 +78,8 @@ private static String createServer(Consumer<Socket> handler) {
7978
}
8079
} catch (Exception e) {
8180
if (e instanceof InterruptedException) {
82-
Thread.currentThread().interrupt();
81+
Thread.currentThread()
82+
.interrupt();
8383
}
8484
throw new RuntimeException(e);
8585
}
@@ -93,7 +93,8 @@ private static String tryGetAddress(Exchanger<Integer> portHolder) {
9393
try {
9494
return "http://localhost:" + portHolder.exchange(0);
9595
} catch (InterruptedException e) {
96-
Thread.currentThread().interrupt();
96+
Thread.currentThread()
97+
.interrupt();
9798
throw new RuntimeException(e);
9899
}
99100
}

0 commit comments

Comments
 (0)