Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 88ce96d

Browse files
committedJul 5, 2017
1412 reused timeouts for waits and covered corner cases for await, renamed state property
1 parent c0af1eb commit 88ce96d

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed
 

‎client/src/main/java/org/asynchttpclient/AsyncHttpClientState.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
public class AsyncHttpClientState {
1919

20-
private final AtomicBoolean closed;
20+
private final AtomicBoolean closeTriggered;
2121

22-
public AsyncHttpClientState(AtomicBoolean closed) {
23-
this.closed = closed;
22+
public AsyncHttpClientState(AtomicBoolean closeTriggered) {
23+
this.closeTriggered = closeTriggered;
2424
}
2525

26-
public boolean isClosedOrClosingIsTriggered() {
27-
return closed.get();
26+
public boolean isCloseTriggered() {
27+
return closeTriggered.get();
2828
}
2929
}

‎client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void close() {
118118

119119
//see https://github.com/netty/netty/issues/2084#issuecomment-44822314
120120
try {
121-
ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS);
121+
ThreadDeathWatcher.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
122122
} catch(InterruptedException t) {
123123
// Ignore
124124
}

‎client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ private void doClose() {
310310

311311
//see https://github.com/netty/netty/issues/2084#issuecomment-44822314
312312
try {
313-
GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS);
313+
GlobalEventExecutor.INSTANCE.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
314314
} catch(InterruptedException t) {
315315
// Ignore
316+
} finally {
317+
closeLatch.countDown();
316318
}
317-
318-
closeLatch.countDown();
319319
}
320320

321321
public void close() {
@@ -326,7 +326,7 @@ public void close() {
326326
doClose();
327327

328328
try {
329-
closeLatch.await();
329+
closeLatch.await(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
330330
}
331331
catch (InterruptedException e) {
332332
// Ignore

‎client/src/main/java/org/asynchttpclient/netty/request/NettyChannelConnector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void connect(final Bootstrap bootstrap, final NettyConnectListener<?> con
7272
try {
7373
connect0(bootstrap, connectListener, remoteAddress);
7474
} catch (RejectedExecutionException e) {
75-
if (clientState.isClosedOrClosingIsTriggered()) {
75+
if (clientState.isCloseTriggered()) {
7676
LOGGER.info("Connect crash but engine is shutting down");
7777
} else {
7878
connectListener.onFailure(null, e);

‎client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc,
597597
}
598598

599599
public boolean isClosed() {
600-
return clientState.isClosedOrClosingIsTriggered();
600+
return clientState.isCloseTriggered();
601601
}
602602

603603
public void drainChannelAndExecuteNextRequest(final Channel channel, final NettyResponseFuture<?> future, Request nextRequest) {

0 commit comments

Comments
 (0)
Please sign in to comment.