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

dmitriusan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 3a6e5ed0ac584946a732cf482d22fb65fbb3c12b
Author: Lisnichenko Dmitro <dlysniche...@hortonworks.com>
AuthorDate: Thu Nov 22 19:04:44 2018 +0200

    AMBARI-24936. Validate cluster name character and length requirements in 
the backend before creating or updating a cluster - address review comments 
(dlysnichenko)
---
 .../ambari/server/controller/AmbariManagementControllerImpl.java      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 05804af..096fc83 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -297,6 +297,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   public static final String SKIP_INSTALL_FOR_COMPONENTS = 
"skipInstallForComponents";
   public static final String DONT_SKIP_INSTALL_FOR_COMPONENTS = 
"dontSkipInstallForComponents";
   public static final String CLUSTER_NAME_VALIDATION_REGEXP = 
"^[a-zA-Z0-9_-]{1,100}$";
+  public static final Pattern CLUSTER_NAME_PTRN = 
Pattern.compile(CLUSTER_NAME_VALIDATION_REGEXP);
 
   private final Clusters clusters;
 
@@ -2182,8 +2183,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     if (clusterName.isEmpty()) {
       throw new IllegalArgumentException("Invalid arguments, cluster name 
should not be empty");
     }
-    Pattern clusterNamePtrn = Pattern.compile(CLUSTER_NAME_VALIDATION_REGEXP);
-    Matcher mtch = clusterNamePtrn.matcher(clusterName);
+    Matcher mtch = CLUSTER_NAME_PTRN.matcher(clusterName);
     if(!mtch.matches()){
       throw new IllegalArgumentException("Invalid arguments, cluster name 
should contains only alphabetical, numeric, '_' and '-' characters and length 
1-100 characters");
     }

Reply via email to