Bläddra i källkod

AMBARI-18623. NPE when a non-existent host is provided as part of the host filter (aonishuk)

Andrew Onishuk 8 år sedan
förälder
incheckning
6dc5a23a76

+ 10 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java

@@ -557,6 +557,16 @@ public class AmbariCustomCommandExecutionHelper {
       candidateHosts = serviceHostComponents.keySet();
     }
 
+    // check if all hostnames are valid.
+    for(String candidateHostName: candidateHosts) {
+      ServiceComponentHost serviceComponentHost = serviceHostComponents.get(candidateHostName);
+
+      if (serviceComponentHost == null) {
+        throw new AmbariException("Provided hostname = "
+            + candidateHostName + " is either not a valid cluster host or does not satisfy the filter condition.");
+      }
+    }
+
     // Filter out hosts that are in maintenance mode - they should never be included in service checks
     Set<String> hostsInMaintenanceMode = new HashSet<String>();
     if (actionExecutionContext.isMaintenanceModeHostExcluded()) {