This is an automated email from the ASF dual-hosted git repository.

liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 385f2b8a0f Fix: Set isClosing flag in closeGracefully method as 
documented (#6263)
385f2b8a0f is described below

commit 385f2b8a0f21dbd472d056f3c8f7244fedfec219
Author: Aira Jena <[email protected]>
AuthorDate: Thu Jan 15 16:40:06 2026 +0530

    Fix: Set isClosing flag in closeGracefully method as documented (#6263)
    
    The FIXME comment noted that the javadoc claimed to use the isClosing
    flag but it wasn't actually being set. This commit:
    
    - Adds isClosing = true at the start of closeGracefully()
    - Updates the javadoc to accurately reflect the behavior
    - Removes the outdated FIXME comment
    
    This ensures new connections are properly rejected during graceful shutdown.
    
    Co-authored-by: aias00 <[email protected]>
---
 .../mcp/server/transport/ShenyuSseServerTransportProvider.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/ShenyuSseServerTransportProvider.java
 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/ShenyuSseServerTransportProvider.java
index 3ff3b29678..f492ae1881 100644
--- 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/ShenyuSseServerTransportProvider.java
+++ 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/ShenyuSseServerTransportProvider.java
@@ -193,18 +193,15 @@ public class ShenyuSseServerTransportProvider implements 
McpServerTransportProvi
                 .then();
     }
 
-    // FIXME: This javadoc makes claims about using isClosing flag but it's not
-    // actually
-    // doing that.
-
     /**
-     * Closes all active sessions gracefully. This method should be called 
when the
-     * transport is shutting down to ensure all sessions are closed properly.
+     * Closes all active sessions gracefully. This method sets the isClosing 
flag
+     * to prevent new connections, then closes all existing sessions properly.
      *
      * @return A Mono that completes when all sessions have been closed
      */
     @Override
     public Mono<Void> closeGracefully() {
+        isClosing = true;
         return Flux.fromIterable(sessions
                 .values())
                 .doFirst(() -> LOGGER.debug("Initiating graceful shutdown with 
{} active sessions", sessions.size()))

Reply via email to