YongGoose commented on code in PR #7576:
URL: https://github.com/apache/incubator-seata/pull/7576#discussion_r2275826574


##########
config/seata-config-consul/src/test/java/org/apache/seata/config/consul/ConsulConfigurationTest.java:
##########
@@ -131,6 +133,31 @@ void testInitSeataConfig() throws Exception {
         assertEquals("val1", value, "KV should be visible after a short 
await");
     }
 
+    @Test
+    void testOnChangeEvent_skipWhenValueIsBlank() throws InterruptedException {
+
+        String dataId = "seata.properties";
+        ConsulConfiguration.ConsulListener listener = new 
ConsulConfiguration.ConsulListener(dataId, null);
+
+        GetValue blankValue = mock(GetValue.class);
+        when(blankValue.getDecodedValue()).thenReturn("");
+
+        Response<GetValue> blankResponse = new Response<>(blankValue, 2L, 
false, 2L);
+        when(mockConsulClient.getKVValue(eq(dataId), isNull(), 
any(QueryParams.class)))
+                .thenReturn(blankResponse);
+
+        // Run onChangeEvent in a separate thread since it loops indefinitely
+        Thread thread = new Thread(() -> listener.onChangeEvent(new 
ConfigurationChangeEvent()));
+        thread.start();
+        Thread.sleep(100);
+        // Interrupt to break the loop
+        thread.interrupt();
+        thread.join(500);

Review Comment:
   What is the purpose of this code?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to