You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2018/11/01 01:09:56 UTC

[ambari] branch branch-2.7 updated: AMBARI-24852. NPE in default host group replacement (#2567)

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

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


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 7186cf4  AMBARI-24852. NPE in default host group replacement (#2567)
7186cf4 is described below

commit 7186cf4034b4ae87e5301eafd3c31622b35150ab
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Thu Nov 1 02:09:51 2018 +0100

    AMBARI-24852. NPE in default host group replacement (#2567)
---
 .../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 19c8e9f..31a157f 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
@@ -1737,6 +1737,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 (?)
@@ -1777,6 +1782,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 996c09d..48e6bac 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
@@ -2248,6 +2248,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()));
@@ -2386,6 +2387,9 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport {
           "%HOSTGROUP::master3%:8080",
           clusterConfig.getProperties(),
           topology)));
+
+    assertEquals(emptyList(),
+      updater.getRequiredHostGroups("mycomponent.urls", null, clusterConfig.getProperties(), topology));
   }
 
   @Test