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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 2574ed4  AMBARI-24852. NPE in default host group replacement (#2571)
2574ed4 is described below

commit 2574ed43e4cb52807d9d4b0e35257fcfbb7815ad
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Nov 2 20:39:16 2018 +0100

    AMBARI-24852. NPE in default host group replacement (#2571)
---
 .../controller/internal/BlueprintConfigurationProcessor.java   | 10 ++++++++++
 .../internal/BlueprintConfigurationProcessorTest.java          |  4 ++++
 2 files changed, 14 insertions(+)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 22ab053..1b62c29 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -1767,6 +1767,11 @@ public class BlueprintConfigurationProcessor {
                                          Map<String, Map<String, String>> 
properties,
                                          ClusterTopology topology) {
 
+      if (origValue == null) {
+        LOG.info("Property {} is null, skipping search for host group 
placeholder", propertyName);
+        return null;
+      }
+
       HostGroups hostGroups = new HostGroups(topology, propertyName);
 
       //todo: getHostStrings (?)
@@ -1807,6 +1812,11 @@ public class BlueprintConfigurationProcessor {
                                                     String origValue,
                                                     Map<String, Map<String, 
String>> properties,
                                                     ClusterTopology topology) {
+      if (origValue == null) {
+        LOG.info("Property {} is null, skipping search for host group 
placeholder", propertyName);
+        return Collections.emptyList();
+      }
+
       //todo: getHostStrings
       Matcher m = HostGroup.HOSTGROUP_REGEX.matcher(origValue);
       Set<String> hostGroups = new HashSet<>();
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
index 28a9bcd..f718862 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java
@@ -2249,6 +2249,7 @@ public class BlueprintConfigurationProcessorTest extends 
EasyMockSupport {
         "dfs.https.address", "testhost3")),
       "myservice-site", new HashMap<>(ImmutableMap.of(
         "myservice_slave_address", "%HOSTGROUP::group1%:8080"))));
+    hostGroupProperties.get("hdfs-site").put("null_property", null);
 
     Configuration clusterConfig = new Configuration(new HashMap<>(), new 
HashMap<>());
     clusterConfig.setParentConfiguration(new Configuration(stackProperties, 
emptyMap()));
@@ -2387,6 +2388,9 @@ public class BlueprintConfigurationProcessorTest extends 
EasyMockSupport {
           "%HOSTGROUP::master3%:8080",
           clusterConfig.getProperties(),
           topology)));
+
+    assertEquals(emptyList(),
+      updater.getRequiredHostGroups("mycomponent.urls", null, 
clusterConfig.getProperties(), topology));
   }
 
   @Test

Reply via email to