Skip to content

Commit

Permalink
fix: closing unexpected channel in internalCloseConnectionIfNeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
okg-cxf committed Aug 16, 2024
1 parent e8d515a commit 8ed038c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1110,16 +1110,17 @@ private boolean shouldNotRetry(Throwable cause) {
}

private void internalCloseConnectionIfNeeded(Throwable reason) {
if (chan.context.isChannelInactiveEventFired() || !chan.isActive()) {
final ContextualChannel chanLocal = this.chan; // the value may be changed in the future, so save it on stack.
if (chanLocal.context.isChannelInactiveEventFired() || !chanLocal.isActive()) {
return;
}

logger.error(
"[internalCloseConnectionIfNeeded][interesting][{}] close the connection due to write error, reason: '{}'",
endpoint.logPrefix(), reason.getMessage(), reason);
chan.eventLoop().schedule(() -> {
if (chan.isActive()) {
chan.close();
chanLocal.eventLoop().schedule(() -> {
if (chanLocal.isActive()) {
chanLocal.close();
}
}, 1, TimeUnit.SECONDS);
}
Expand Down

0 comments on commit 8ed038c

Please sign in to comment.