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


##########
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:
   > I also see `return` statements in other configuration code. And please 
don’t close the conversation while it’s still ongoing.
   
   That's because other configuration types passively receive change push 
notifications. If an empty configuration is received, just return it directly. 
consul, on the other hand, requires the client to continuously undergo 
long-term training (active acquisition) at regular intervals.
   
   



-- 
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-unsubscr...@seata.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to