Arsnael commented on code in PR #2481:
URL: https://github.com/apache/james-project/pull/2481#discussion_r1825351362


##########
server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java:
##########
@@ -131,17 +133,29 @@ public void authenticated() {
     @Override
     public Mono<Void> deselect() {
         this.state = ImapSessionState.AUTHENTICATED;
+        if (getAttribute(MDC_KEY) instanceof MDCBuilder mdcBuilder) {
+            setAttribute(MDC_KEY, mdcBuilder
+                .addToContext("selectedMailbox", ""));
+        }
         return closeMailbox();
     }
 
     @Override
     public Mono<Void> selected(SelectedMailbox mailbox) {
         this.state = ImapSessionState.SELECTED;
-        return Mono.fromCallable(() -> 
Optional.ofNullable(selectedMailbox.getAndSet(mailbox)))
+        return Mono.fromCallable(() -> {
+                addSelectedMailboxToMDC(mailbox);
+                return Optional.ofNullable(selectedMailbox.getAndSet(mailbox));
+            })
             .flatMap(maybeMailbox -> 
maybeMailbox.map(SelectedMailbox::deselect)
                 .orElse(Mono.empty()));
     }
 
+    private void addSelectedMailboxToMDC(SelectedMailbox mailbox) {
+        setAttribute(MDC_KEY, mdc()
+            .addToContext("selectedMailbox", 
mailbox.getMailboxId().serialize());

Review Comment:
   Missing ")" in the end indeed



-- 
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: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to