You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2024/01/13 10:10:22 UTC

(dubbo) branch revert-13343-3.2-feature-checkAppName created (now de49f8a01b)

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

albumenj pushed a change to branch revert-13343-3.2-feature-checkAppName
in repository https://gitbox.apache.org/repos/asf/dubbo.git


      at de49f8a01b Revert "check application name"

This branch includes the following new commits:

     new de49f8a01b Revert "check application name"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(dubbo) 01/01: Revert "check application name"

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch revert-13343-3.2-feature-checkAppName
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit de49f8a01bf30f27b086a4b9b7f1c82d25783141
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Sat Jan 13 18:10:17 2024 +0800

    Revert "check application name"
---
 .../dubbo/config/utils/ConfigValidationUtils.java      | 18 +++++-------------
 .../org/apache/dubbo/config/ReferenceConfigTest.java   |  2 +-
 .../dubbo/config/utils/ConfigValidationUtilsTest.java  |  3 ---
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
index afa057ae7f..728aa21845 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
@@ -491,12 +491,6 @@ public class ConfigValidationUtils {
                     + "Please add <dubbo:application name=\"...\" /> to your spring config.");
         }
 
-        String name = config.getName();
-        if (!checkName(NAME, name)) {
-            throw new IllegalStateException(
-                    String.format("please correct dubbo application name: %s at your spring config.", name));
-        }
-
         // backward compatibility
         ScopeModel scopeModel = ScopeModelUtil.getOrDefaultApplicationModel(config.getScopeModel());
         PropertiesConfiguration configuration = scopeModel.modelEnvironment().getPropertiesConfiguration();
@@ -510,6 +504,7 @@ public class ConfigValidationUtils {
             }
         }
 
+        checkName(NAME, config.getName());
         checkMultiName(OWNER, config.getOwner());
         checkName(ORGANIZATION, config.getOrganization());
         checkName(ARCHITECTURE, config.getArchitecture());
@@ -737,8 +732,8 @@ public class ConfigValidationUtils {
         checkProperty(property, value, MAX_PATH_LENGTH, null);
     }
 
-    public static boolean checkName(String property, String value) {
-        return checkProperty(property, value, MAX_LENGTH, PATTERN_NAME);
+    public static void checkName(String property, String value) {
+        checkProperty(property, value, MAX_LENGTH, PATTERN_NAME);
     }
 
     public static void checkHost(String property, String value) {
@@ -794,9 +789,9 @@ public class ConfigValidationUtils {
         }
     }
 
-    public static boolean checkProperty(String property, String value, int maxlength, Pattern pattern) {
+    public static void checkProperty(String property, String value, int maxlength, Pattern pattern) {
         if (StringUtils.isEmpty(value)) {
-            return false;
+            return;
         }
         if (value.length() > maxlength) {
             logger.error(
@@ -805,7 +800,6 @@ public class ConfigValidationUtils {
                     "",
                     "Parameter value format error. Invalid " + property + "=\"" + value + "\" is longer than "
                             + maxlength);
-            return false;
         }
         if (pattern != null) {
             Matcher matcher = pattern.matcher(value);
@@ -817,9 +811,7 @@ public class ConfigValidationUtils {
                         "Parameter value format error. Invalid " + property
                                 + "=\"" + value + "\" contains illegal "
                                 + "character, only digit, letter, '-', '_' or '.' is legal.");
-                return false;
             }
         }
-        return true;
     }
 }
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
index 7b67217e57..983c19299a 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
@@ -873,7 +873,7 @@ class ReferenceConfigTest {
         referenceConfig.setGeneric("true");
 
         DubboBootstrap.getInstance()
-                .application("demo-app")
+                .application("demo app")
                 .reference(referenceConfig)
                 .initialize();
 
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ConfigValidationUtilsTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ConfigValidationUtilsTest.java
index 5cb5036e69..fb6dae095c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ConfigValidationUtilsTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ConfigValidationUtilsTest.java
@@ -100,9 +100,6 @@ class ConfigValidationUtilsTest {
             mockedStatic
                     .when(() -> ConfigValidationUtils.validateApplicationConfig(any()))
                     .thenCallRealMethod();
-            mockedStatic
-                    .when(() -> ConfigValidationUtils.checkName(any(), any()))
-                    .thenReturn(true);
             ApplicationConfig config = new ApplicationConfig();
             Assertions.assertThrows(IllegalStateException.class, () -> {
                 ConfigValidationUtils.validateApplicationConfig(config);