RockteMQ-AI commented on PR #10597:
URL: https://github.com/apache/rocketmq/pull/10597#issuecomment-4913426171
## Review by github-manager-bot (Incremental — commits 7b01e0f..1a8e7b5)
### Summary
Two follow-up commits that refactor
`testSubscribeRouteEvents_DelegatesToNotifier` to use a behavioral verification
approach (CountDownLatch + anonymous RouteChangeNotifier subclass) instead of
Mockito `verify()`, and properly annotate `adminClientService` with `@Mock`.
### Findings
- **[Warning]** `proxy/src/test/java/.../ProxyAdminGrpcServiceTest.java:89`
— `MockitoAnnotations.initMocks(this)` has been deprecated since Mockito 3.x.
Consider using `MockitoAnnotations.openMocks(this)` instead, which returns an
`AutoCloseable` that should be stored and closed in `@After` to avoid resource
leaks:
```java
private AutoCloseable mocks;
@Before
public void before() {
mocks = MockitoAnnotations.openMocks(this);
adminGrpcService = new ProxyAdminGrpcService(adminClientService, 2);
}
@After
public void after() throws Exception {
if (mocks != null) mocks.close();
}
```
- **[Info]**
`proxy/src/test/java/.../ProxyAdminGrpcServiceTest.java:696-703` — The test
refactoring looks good. Using a `CountDownLatch` with a behavioral override of
`RouteChangeNotifier.subscribe()` is a cleaner way to verify the end-to-end
delegation than `verify(notifier).subscribe(any(), any(), any())`. The 5-second
timeout provides adequate safety against hangs.
- **[Info]** The `routeChangeNotifier` field is reassigned inside the test
method before being passed to the constructor. This works correctly but note
that the field-level `routeChangeNotifier` (used by `@Before` to construct the
default `adminGrpcService`) is a separate instance from the one used by
`serviceWithNotifier`. This is intentional and fine.
### Verdict
Minor deprecation warning only. The test improvement is solid.
---
*Automated review by github-manager-bot*
--
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]