wy471x opened a new pull request, #7171:
URL: https://github.com/apache/shenyu/pull/7171

   <!-- Fixes #6665 -->
   Make sure that:
   
   - [X] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [X] You submit test cases (unit or integration tests) that back your 
changes.
   - [X] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   
   ## Summary
   
   `SpringWebSocketClientEventListener#buildMetaDataDTO` hardcoded 
`.enabled(true)` when building the `MetaDataRegisterDTO`, so 
`@ShenyuSpringWebSocketClient(enabled = false)` was silently ignored and the 
websocket route stayed live after being "disabled". Every other client honours 
the attribute (SOFA `.enabled(shenyuSofaClient.enabled())`, Tars 
`.enabled(shenyuTarsClient.enabled())`, MCP 
`setEnabled(shenyuMcpTool.getEnable())`); WebSocket was the only one that did 
not.
   
   ### Changes:
   
   1. `SpringWebSocketClientEventListener#buildMetaDataDTO` 
(`shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java:229`)
 — `.enabled(true)` replaced with `.enabled(webSocketClient.enabled())`. The 
`enabled` attribute already exists on `@ShenyuSpringWebSocketClient` 
(`ShenyuSpringWebSocketClient.java:68`, default `true`), so no annotation/API 
change is required and the default behaviour is unchanged.
   
   ### Test Cases:
   
   1. 
`SpringWebSocketClientEventListenerTest#testBuildMetaDataDTOShouldRespectEnabledAttribute`
 (new, `.../init/SpringWebSocketClientEventListenerTest.java`) — builds the 
metadata from the real merged annotation of two endpoint classes, one using the 
default (`enabled = true`) and one annotated 
`@ShenyuSpringWebSocketClient(enabled = false)`, and asserts `isEnabled()` is 
`true` / `false` respectively. With the old hardcoded `.enabled(true)` the 
disabled case fails.
   2. Existing `SpringWebSocketClientEventListenerTest` cases (12) still pass, 
confirming registration behaviour is otherwise unchanged.
   
   ## Verification
   
   - `mvn -pl 
shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket -am test 
-Dtest=SpringWebSocketClientEventListenerTest` (JDK 21): `Tests run: 13, 
Failures: 0, Errors: 0, Skipped: 0`.
   - `mvn clean install -Dmaven.javadoc.skip=true` (JDK 21): BUILD SUCCESS in 
14:23 min, checkstyle + RAT included.
   
   Fixes #6665
   


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