Copilot commented on code in PR #10789:
URL: https://github.com/apache/rocketmq/pull/10789#discussion_r3702326055


##########
proxy/src/test/java/org/apache/rocketmq/proxy/grpc/v2/common/GrpcClientSettingsManagerTest.java:
##########
@@ -76,6 +78,36 @@ public void testGetProducerData() {
         assertNotEquals(settings.getPublishing(), 
settings.getPublishing().getDefaultInstanceForType());
     }
 
+    @Test
+    public void testMergeMetricWithValidCollectorAddress() {
+        
ConfigurationManager.getProxyConfig().setMetricCollectorMode(MetricCollectorMode.ON.getModeString());
+        
ConfigurationManager.getProxyConfig().setMetricCollectorAddress("127.0.0.1:9090");
+        try {
+            Settings settings = 
this.grpcClientSettingsManager.mergeMetric(Settings.getDefaultInstance());
+
+            assertEquals(true, settings.getMetric().getOn());
+            assertEquals("127.0.0.1", 
settings.getMetric().getEndpoints().getAddresses(0).getHost());
+            assertEquals(9090, 
settings.getMetric().getEndpoints().getAddresses(0).getPort());
+        } finally {
+            
ConfigurationManager.getProxyConfig().setMetricCollectorMode(MetricCollectorMode.OFF.getModeString());
+            
ConfigurationManager.getProxyConfig().setMetricCollectorAddress("");
+        }
+    }

Review Comment:
   These tests mutate the global ProxyConfig via ConfigurationManager and then 
restore it to hard-coded defaults (OFF/empty). That can make the test suite 
order-dependent/flaky if other tests rely on non-default metric settings. 
Capture the original values and restore them in the finally block instead.
   
   This issue also appears on line 99 of the same file.



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