Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
1412 reused timeouts for waits and covered corner cases for await, re…
…named state property
  • Loading branch information
MiErnst committed Jul 5, 2017
commit 88ce96d97073f856c56c83dbdde3545ef75a7dcb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

public class AsyncHttpClientState {

private final AtomicBoolean closed;
private final AtomicBoolean closeTriggered;

public AsyncHttpClientState(AtomicBoolean closed) {
this.closed = closed;
public AsyncHttpClientState(AtomicBoolean closeTriggered) {
this.closeTriggered = closeTriggered;
}

public boolean isClosedOrClosingIsTriggered() {
return closed.get();
public boolean isCloseTriggered() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with the old name?

return closeTriggered.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void close() {

//see https://github.com/netty/netty/issues/2084#issuecomment-44822314
try {
ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS);
ThreadDeathWatcher.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
} catch(InterruptedException t) {
// Ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-assert interrupted status

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ private void doClose() {

//see https://github.com/netty/netty/issues/2084#issuecomment-44822314
try {
GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS);
GlobalEventExecutor.INSTANCE.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
} catch(InterruptedException t) {
// Ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-assert interrupted status

} finally {
closeLatch.countDown();
}

closeLatch.countDown();
}

public void close() {
Expand All @@ -326,7 +326,7 @@ public void close() {
doClose();

try {
closeLatch.await();
closeLatch.await(config.getShutdownTimeout(), TimeUnit.MILLISECONDS);
}
catch (InterruptedException e) {
// Ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-assert interrupted status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void connect(final Bootstrap bootstrap, final NettyConnectListener<?> con
try {
connect0(bootstrap, connectListener, remoteAddress);
} catch (RejectedExecutionException e) {
if (clientState.isClosedOrClosingIsTriggered()) {
if (clientState.isCloseTriggered()) {
LOGGER.info("Connect crash but engine is shutting down");
} else {
connectListener.onFailure(null, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public void replayRequest(final NettyResponseFuture<?> future, FilterContext fc,
}

public boolean isClosed() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename method too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and attached another commit to the pull request!

return clientState.isClosedOrClosingIsTriggered();
return clientState.isCloseTriggered();
}

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