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

       ### Incremental Update: Handler Installation Guard & Strict LOGOUT 
Matching
   
       Based on review feedback, applied the following targeted refinements:
   
       1. **Guarded `session.popLineHandler()` against uninitialized state**:
          - **Issue**: If an exception occurred during IDLE initialization 
before `session.pushLineHandler(...)` was reached, the error cleanup logic 
would attempt to invoke `session.popLineHandler()`, risking underflowing the 
Netty
     handler stack or removing the wrong handler.
          - **Fix**: Introduced a dedicated `AtomicBoolean 
lineHandlerInstalled` flag set strictly after `session.pushLineHandler(...)` 
succeeds. `cleanupIdle(...)` now checks `lineHandlerInstalled.get()` before 
invoking `session.
     popLineHandler()`.
   
       2. **Strict IMAP Command Matching for mid-IDLE `LOGOUT`**:
          - **Issue**: Checking `line.endsWith("LOGOUT")` was overly permissive 
and could inadvertently trigger session termination on arbitrary continuation 
strings ending in `"LOGOUT"`.
          - **Fix**: Narrowed matching to strict IMAP syntax: 
`upper.equals("LOGOUT") || upper.matches("^\\S+\\s+LOGOUT$")` (matches 
standalone `LOGOUT` or tagged `<tag> LOGOUT` only).
   
       3. **Reverted `ImapIdleStateHandler` to Standard `ALL_IDLE`**:
          - Preserved standard `ALL_IDLE` behavior to ensure silent, legitimate 
IDLE clients receiving periodic server heartbeats are never dropped by Netty. 
Connection liveness is handled safely via `ImapSession#isConnected` (`channel.
     isActive()`).
   
       #### Verification
       - Modules `:protocols-imap` and `:james-server-protocols-imap4` compiled 
successfully (`BUILD SUCCESS`).
       - Checkstyle: **0 violations**.


-- 
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