Skip to content

Suppress noisy WriteToClosedSessionException errors on session teardown#1143

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/investigate-exception-increase
Draft

Suppress noisy WriteToClosedSessionException errors on session teardown#1143
Copilot wants to merge 2 commits intomasterfrom
copilot/investigate-exception-increase

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Since closeOnFlush() was adopted (#543), in-flight writes (including TLS close_notify frames) are flushed before the session closes. If the underlying channel is already gone, MINA's write queue cleanup throws WriteToClosedSessionException and routes it to exceptionCaught(). Because WriteToClosedSessionException → WriteException → IOException, it was being treated as a real socket error — triggering redundant disconnect() calls or log.error when the QF session was already detached — producing a flood of error-level noise on every disconnect.

Changes

  • AbstractIoHandler.exceptionCaught() — intercept WriteToClosedSessionException before the IOException branch; log at DEBUG and return early (no disconnect, no QFJ_RESET_IO_CONNECTOR attribute set, since the session is already gone)
  • AcceptorIoHandlerTest — add testWriteToClosedSessionExceptionIsHandledGracefully verifying that setAttribute(QFJ_RESET_IO_CONNECTOR) is not called when this exception is caught
if (realCause instanceof WriteToClosedSessionException) {
    log.debug("Write to closed session ({}): {}", ioSession.getRemoteAddress(), cause.getMessage());
    return;
} else if (realCause instanceof IOException) {
    // ...existing handling
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…(QFJ-928)

Co-authored-by: chrjohn <6644028+chrjohn@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate reason for increase in exceptions Suppress noisy WriteToClosedSessionException errors on session teardown Feb 19, 2026
Copilot AI requested a review from chrjohn February 19, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants