You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/05/07 01:24:33 UTC
[PR] Fix duplicate full-mode URI heartbeat registration after repeated refresh [shenyu]
Aias00 opened a new pull request, #6337:
URL: https://github.com/apache/shenyu/pull/6337
Fixes duplicate full-mode URI registration when the client receives repeated `ContextRefreshedEvent` callbacks.
## Summary
- route full-mode Spring MVC and WebSocket registration through the shared one-time registration gate
- remove duplicated direct publisher fields from the concrete listeners and reuse the base publisher access
- add regression tests covering repeated refresh events for both full-mode listeners
## Verification
- [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.
- [ ] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`.
Test command run:
`mvn -pl shenyu-client/shenyu-client-core,shenyu-client/shenyu-client-http/shenyu-client-springmvc,shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket -am -DfailIfNoTests=false -Dtest=ShenyuClientURIExecutorSubscriberTest,SpringMvcClientEventListenerTest,SpringWebSocketClientEventListenerTest test`
--
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-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate full-mode URI heartbeat registration after repeated refresh [shenyu]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6337:
URL: https://github.com/apache/shenyu/pull/6337#discussion_r3198439324
##########
shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java:
##########
@@ -85,20 +89,7 @@ public class SpringWebSocketClientEventListenerTest {
@BeforeEach
public void setUp() {
MockitoAnnotations.openMocks(this);
- Properties properties = mock(Properties.class);
- when(properties.getProperty("appName")).thenReturn("appName");
- when(properties.getProperty("contextPath")).thenReturn("contextPath");
- when(properties.getProperty(ShenyuClientConstants.PORT)).thenReturn("8080");
- when(properties.getProperty(ShenyuClientConstants.HOST)).thenReturn("127.0.0.1");
- when(properties.getProperty(ShenyuClientConstants.IP_PORT)).thenReturn("127.0.0.1:8080");
-
- ShenyuClientConfig clientConfig = mock(ShenyuClientConfig.class);
- Map<String, ClientPropertiesConfig> client = new HashMap<>();
- ClientPropertiesConfig clientPropertiesConfig = new ClientPropertiesConfig();
- clientPropertiesConfig.setProps(properties);
- client.put(RpcTypeEnum.WEB_SOCKET.getName(), clientPropertiesConfig);
- when(clientConfig.getClient()).thenReturn(client);
- eventListener = new SpringWebSocketClientEventListener(clientConfig, registerRepository);
+ eventListener = buildEventListener(false);
Review Comment:
`@ExtendWith(MockitoExtension.class)` already initializes/cleans up mocks. Calling `MockitoAnnotations.openMocks(this)` here is redundant and the returned `AutoCloseable` is not closed, which can leak Mockito resources across tests. Remove the `openMocks` call (preferred) or store/close it in an `@AfterEach`.
--
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-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate full-mode URI heartbeat registration after repeated refresh [shenyu]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on code in PR #6337:
URL: https://github.com/apache/shenyu/pull/6337#discussion_r3198460695
##########
shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java:
##########
@@ -85,20 +89,7 @@ public class SpringWebSocketClientEventListenerTest {
@BeforeEach
public void setUp() {
MockitoAnnotations.openMocks(this);
- Properties properties = mock(Properties.class);
- when(properties.getProperty("appName")).thenReturn("appName");
- when(properties.getProperty("contextPath")).thenReturn("contextPath");
- when(properties.getProperty(ShenyuClientConstants.PORT)).thenReturn("8080");
- when(properties.getProperty(ShenyuClientConstants.HOST)).thenReturn("127.0.0.1");
- when(properties.getProperty(ShenyuClientConstants.IP_PORT)).thenReturn("127.0.0.1:8080");
-
- ShenyuClientConfig clientConfig = mock(ShenyuClientConfig.class);
- Map<String, ClientPropertiesConfig> client = new HashMap<>();
- ClientPropertiesConfig clientPropertiesConfig = new ClientPropertiesConfig();
- clientPropertiesConfig.setProps(properties);
- client.put(RpcTypeEnum.WEB_SOCKET.getName(), clientPropertiesConfig);
- when(clientConfig.getClient()).thenReturn(client);
- eventListener = new SpringWebSocketClientEventListener(clientConfig, registerRepository);
+ eventListener = buildEventListener(false);
Review Comment:
Removed `MockitoAnnotations.openMocks(this)` and the unused import. `@ExtendWith(MockitoExtension.class)` now owns mock initialization for this test.
--
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-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate full-mode URI heartbeat registration after repeated refresh [shenyu]
Posted by "moremind (via GitHub)" <gi...@apache.org>.
moremind merged PR #6337:
URL: https://github.com/apache/shenyu/pull/6337
--
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-unsubscribe@shenyu.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org