zhang-arvin commented on PR #6997:
URL: https://github.com/apache/shenyu/pull/6997#issuecomment-5770396653

   @Copilot Thanks — the compile error was real and is now fixed.
   
   You were right that `sessionId` is declared `final` (line 1047) and is 
already assigned by both constructors, so `setSessionId()` could not assign to 
it. Confirmed with a local build on the previous head:
   
   ```
   [ERROR] ShenyuStreamableHttpServerTransportProvider.java:[1073,17] 
无法为最终变量sessionId分配值
   ```
   
   (the compiler's `cannot assign a value to final variable sessionId`).
   
   **Fix:** dropped the `final` modifier so `setSessionId()` can synchronize 
the transport's ID with the key the provider registers the session under. That 
synchronization is the whole point of this PR — without it `close()` looked up 
an ID that never existed in `sessions` / `sessionTransports` and left both 
registries (plus `ShenyuMcpExchangeHolder`) populated forever.
   
   **Regression test added**, addressing your second comment: after a real 
initialize handshake, the session ID returned to the client via 
`Mcp-Session-Id` must be exactly the key used in both `sessions` and 
`sessionTransports` — i.e. the ID `close()` will later look up. Verified:
   
   `./mvnw -pl shenyu-plugin/shenyu-plugin-mcp-server test 
-Dtest=ShenyuStreamableHttpServerTransportProviderTest` → **Tests run: 6, 
Failures: 0, Errors: 0**.
   
   I also re-verified the fix is load-bearing by restoring `final` locally — 
the module then fails to compile at line 1073, so the change and its test are 
not vacuous.
   
   @Aias00 the branch is synced with `master`. Would you mind taking another 
look?


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

Reply via email to