Skip to content

Commit 6a3391f

Browse files
committed
Make mcpHandler volatile and contextExtractor final
1 parent 9bbfbe5 commit 6a3391f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/server/transport/HttpServletStatelessServerTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public class HttpServletStatelessServerTransport extends HttpServlet implements
5252

5353
private final String mcpEndpoint;
5454

55-
private McpStatelessServerHandler mcpHandler;
55+
private volatile McpStatelessServerHandler mcpHandler;
5656

57-
private McpTransportContextExtractor<HttpServletRequest> contextExtractor;
57+
private final McpTransportContextExtractor<HttpServletRequest> contextExtractor;
5858

5959
private volatile boolean isClosing = false;
6060

mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/server/transport/WebFluxStatelessServerTransport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
package io.modelcontextprotocol.server.transport;
66

7-
import io.modelcontextprotocol.json.McpJsonMapper;
87
import io.modelcontextprotocol.common.McpTransportContext;
8+
import io.modelcontextprotocol.json.McpJsonMapper;
99
import io.modelcontextprotocol.server.McpStatelessServerHandler;
1010
import io.modelcontextprotocol.server.McpTransportContextExtractor;
1111
import io.modelcontextprotocol.spec.McpError;
@@ -40,9 +40,9 @@ public class WebFluxStatelessServerTransport implements McpStatelessServerTransp
4040

4141
private final RouterFunction<?> routerFunction;
4242

43-
private McpStatelessServerHandler mcpHandler;
43+
private volatile McpStatelessServerHandler mcpHandler;
4444

45-
private McpTransportContextExtractor<ServerRequest> contextExtractor;
45+
private final McpTransportContextExtractor<ServerRequest> contextExtractor;
4646

4747
private volatile boolean isClosing = false;
4848

mcp-spring/mcp-spring-webmvc/src/main/java/io/modelcontextprotocol/server/transport/WebMvcStatelessServerTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public class WebMvcStatelessServerTransport implements McpStatelessServerTranspo
4444

4545
private final RouterFunction<ServerResponse> routerFunction;
4646

47-
private McpStatelessServerHandler mcpHandler;
47+
private volatile McpStatelessServerHandler mcpHandler;
4848

49-
private McpTransportContextExtractor<ServerRequest> contextExtractor;
49+
private final McpTransportContextExtractor<ServerRequest> contextExtractor;
5050

5151
private volatile boolean isClosing = false;
5252

0 commit comments

Comments
 (0)