You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "YongGoose (via GitHub)" <gi...@apache.org> on 2025/08/14 08:13:35 UTC

Re: [PR] optimize: Add empty push protection for Configuration [incubator-seata]

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: notifications-unsubscribe@seata.apache.org

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


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