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

albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 84d8cc2002 fix: toCommaDelimitedString returns "null,null" when inputs 
are null (#15338)
84d8cc2002 is described below

commit 84d8cc2002d277ab7df8f11c9c35345cb997bb33
Author: Ankit Shokeen <[email protected]>
AuthorDate: Thu May 8 07:20:12 2025 +0530

    fix: toCommaDelimitedString returns "null,null" when inputs are null 
(#15338)
    
    * fix: return 'one' if others is null in toCommaDelimitedString
    
    * fix:
---
 .../java/org/apache/dubbo/common/utils/StringUtils.java    | 14 ++++++++++----
 .../org/apache/dubbo/common/utils/StringUtilsTest.java     |  4 ++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
index 78ee6f5530..73e4dc1c3f 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
@@ -1242,14 +1242,20 @@ public final class StringUtils {
     }
 
     /**
-     * Create the common-delimited {@link String} by one or more {@link 
String} members
+     * Creates a comma-delimited string from one or more string values.
      *
-     * @param one    one {@link String}
-     * @param others others {@link String}
-     * @return <code>null</code> if <code>one</code> or <code>others</code> is 
<code>null</code>
+     * @param one    the first string value
+     * @param others additional string values
+     * @return the combined string, or null if the first value is null
      * @since 2.7.8
      */
     public static String toCommaDelimitedString(String one, String... others) {
+        if (one == null) {
+            return null;
+        }
+        if (others == null) {
+            return one;
+        }
         String another = arrayToDelimitedString(others, COMMA_SEPARATOR);
         return isEmpty(another) ? one : one + COMMA_SEPARATOR + another;
     }
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/StringUtilsTest.java 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/StringUtilsTest.java
index 3be95a78ed..484054f53e 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/StringUtilsTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/StringUtilsTest.java
@@ -474,6 +474,7 @@ class StringUtilsTest {
 
     /**
      * Test {@link StringUtils#toCommaDelimitedString(String, String...)}
+     *
      * @since 2.7.8
      */
     @Test
@@ -484,6 +485,9 @@ class StringUtilsTest {
         value = toCommaDelimitedString(null, null);
         assertNull(value);
 
+        value = toCommaDelimitedString("one", null);
+        assertEquals("one", value);
+
         value = toCommaDelimitedString("");
         assertEquals("", value);
 

Reply via email to