prosgarz35 commented on PR #3198:
URL: https://github.com/apache/james-project/pull/3198#issuecomment-5807646080

       ### PR Update: Concurrency Hardening & Comprehensive IDLE Lifecycle 
Verification
   
       #### 1. Reactor Non-Blocking & Idempotent Teardown
       - **Replaced `CountDownLatch` with `Sinks.One<Void> idleReadySink`**: 
Eliminated thread-starvation risks on Reactor event loops. Listener 
registration is coordinated reactively without blocking worker threads.
       - **Atomic Cleanup Guard**: Introduced `AtomicBoolean idleActive` 
combined with explicit instance binding to the active `SelectedMailbox`. This 
guarantees strictly idempotent teardown (`compareAndSet(true, false)`) across 
`DONE`,
     invalid continuations, unexpected disconnections, and heartbeat 
terminations.
       - **Line Handler Lifecycle Guard**: Added `AtomicBoolean 
lineHandlerInstalled` to prevent double-popping or premature pops when tearing 
down idle handlers.
       - **Immediate Sink Teardown**: Ensured `idleReadySink.tryEmitEmpty()` 
triggers promptly on disconnect/error to guarantee any pending reactive 
subscriptions terminate without leaks.
   
       #### 2. Strict RFC 2177 Compliance
       - Cleanly decoupled standard continuation processing: strictly matches 
`DONE` (case-insensitive).
       - Unexpected continuations (e.g. `LOGOUT`, invalid tokens) return 
standard tagged `BAD IDLE failed...` while cleanly unregistering mailbox 
listeners and popping the line handler, leaving the session ready for 
subsequent commands.
   
       #### 3. Test Coverage & Verification (Netty Integration + Unit Tests)
       - **Netty Integration Tests 
([`IMAPServerIdleTest`](https://github.com/apache/james-project/pull/3198))**:
         - `invalidContinuationShouldEndIdleAndAllowSubsequentCommands`: 
Validates RFC 2177 `BAD` response on malformed continuations and confirms the 
line handler is popped, allowing subsequent commands (e.g., `NOOP`) to succeed
     immediately.
         - `midIdleLogoutShouldRejectContinuationAndAllowSubsequentLogout`: 
Validates rejection of naked continuation commands with tagged `BAD`, followed 
by a successful subsequent tagged `LOGOUT`.
         - `disconnectDuringIdleShouldCleanlyDecrementConnections`: Validates 
abrupt TCP socket drops during active IDLE, ensuring listener unregistration 
and clean connection counter decrement (`imapConnections == 0`).
         - *Result*: 61 of 61 passed locally (0 failures, 0 errors).
       - **Unit Tests 
([`IdleProcessorTest`](https://github.com/apache/james-project/pull/3198))**:
         - Verifies heartbeat abortion when `session.isConnected() == false` 
without rescheduling.
         - Verifies graceful handling and cleanup of empty lines and malformed 
continuations.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to