You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by li...@apache.org on 2026/09/05 15:09:32 UTC

(shenyu) branch master updated: fix: update HuaweiLtsLogCollectClient to use dedicated configuration for GiveUpExtraLongSingleLog and add corresponding test case (#6949)

This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new bcb8efe644 fix: update HuaweiLtsLogCollectClient to use dedicated configuration for GiveUpExtraLongSingleLog and add corresponding test case (#6949)
bcb8efe644 is described below

commit bcb8efe6443c970cefd2be3bd36065f208064570
Author: Limbo <yy...@qq.com>
AuthorDate: Sat Sep 5 23:09:25 2026 +0800

    fix: update HuaweiLtsLogCollectClient to use dedicated configuration for GiveUpExtraLongSingleLog and add corresponding test case (#6949)
    
    Co-authored-by: aias00 <li...@apache.org>
---
 .../lts/client/HuaweiLtsLogCollectClient.java      |  2 +-
 .../lts/client/HuaweiLtsLogCollectClientTest.java  | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/main/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClient.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/main/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClient.java
index 8e13ec31ff..b0df92cda4 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/main/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClient.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/main/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClient.java
@@ -97,7 +97,7 @@ public class HuaweiLtsLogCollectClient extends AbstractLogConsumeClient<HuaweiLo
                 .setBaseRetryBackoffMs(huaweiLtsLogConfig.getBaseRetryBackoffMs())
                 .setMaxRetryBackoffMs(huaweiLtsLogConfig.getMaxRetryBackoffMs())
                 .setEnableLocalTest(Boolean.parseBoolean(huaweiLtsLogConfig.getEnableLocalTest()))
-                .setGiveUpExtraLongSingleLog(Boolean.parseBoolean(huaweiLtsLogConfig.getEnableLocalTest()))
+                .setGiveUpExtraLongSingleLog(Boolean.parseBoolean(huaweiLtsLogConfig.getSetGiveUpExtraLongSingleLog()))
                 .builder();
         this.producer = appender.getProducer();
 
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/test/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClientTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/test/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClientTest.java
index 7f435a2a14..f70fa1cd32 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/test/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClientTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-huawei-lts/src/test/java/org/apache/shenyu/plugin/huawei/lts/client/HuaweiLtsLogCollectClientTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shenyu.plugin.huawei.lts.client;
 
+import com.huaweicloud.lts.appender.JavaSDKAppender;
+import com.huaweicloud.lts.producer.Producer;
 import org.apache.shenyu.common.dto.PluginData;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.plugin.huawei.lts.config.HuaweiLogCollectConfig;
@@ -24,6 +26,8 @@ import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
 
 import java.lang.reflect.Field;
 import java.util.ArrayList;
@@ -69,6 +73,25 @@ public class HuaweiLtsLogCollectClientTest {
         huaweiLtsLogCollectClient.close();
     }
 
+    @Test
+    public void testGiveUpExtraLongSingleLogUsesDedicatedConfig() throws Exception {
+        huaweiLtsLogConfig.setEnableLocalTest("true");
+        huaweiLtsLogConfig.setSetGiveUpExtraLongSingleLog("false");
+        JavaSDKAppender.Builder builder = Mockito.mock(JavaSDKAppender.Builder.class, Mockito.RETURNS_SELF);
+        JavaSDKAppender appender = Mockito.mock(JavaSDKAppender.class);
+        Producer producer = Mockito.mock(Producer.class);
+        Mockito.when(builder.builder()).thenReturn(appender);
+        Mockito.when(appender.getProducer()).thenReturn(producer);
+
+        try (MockedStatic<JavaSDKAppender> appenderMockedStatic = Mockito.mockStatic(JavaSDKAppender.class)) {
+            appenderMockedStatic.when(JavaSDKAppender::custom).thenReturn(builder);
+            huaweiLtsLogCollectClient.initClient0(huaweiLtsLogConfig);
+        }
+
+        Mockito.verify(builder).setEnableLocalTest(true);
+        Mockito.verify(builder).setGiveUpExtraLongSingleLog(false);
+    }
+
     @Test
     public void testConsume() {
         String msg = "";