ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [2/2] ambari git commit: AMBARI-22297. Initialize blueprint with default values to avoid NPE (adoroszlai)
Date Mon, 20 Nov 2017 10:17:36 GMT
AMBARI-22297. Initialize blueprint with default values to avoid NPE (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/94a93a6b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/94a93a6b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/94a93a6b

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: 94a93a6bbe7495f7ed133fbd8df597609ac34fa7
Parents: 365980b
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Mon Nov 20 08:55:08 2017 +0100
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Mon Nov 20 10:19:15 2017 +0100

----------------------------------------------------------------------
 .../ambari/server/topology/BlueprintV2Impl.java       | 14 +++++++-------
 .../apache/ambari/server/topology/Configuration.java  |  4 ++++
 .../ambari/server/topology/SecurityConfiguration.java |  2 ++
 .../org/apache/ambari/server/topology/Service.java    |  2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/94a93a6b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Impl.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Impl.java
index 26bdfe2..66ca85d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Impl.java
@@ -23,8 +23,8 @@ import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toMap;
 import static java.util.stream.Collectors.toSet;
 
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -48,11 +48,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 public class BlueprintV2Impl implements BlueprintV2 {
 
   private String name;
-  private SecurityConfiguration securityConfiguration;
-  private Collection<RepositoryVersion> repositoryVersions = new ArrayList<>(0);
-  private Map<String, ServiceGroup> serviceGroups;
-  private Setting setting;
-  private final Configuration configuration = new Configuration(new HashMap<>(), new
HashMap<>());
+  private SecurityConfiguration securityConfiguration = SecurityConfiguration.NONE;
+  private Collection<RepositoryVersion> repositoryVersions = Collections.emptyList();
+  private Map<String, ServiceGroup> serviceGroups = Collections.emptyMap();
+  private Setting setting = new Setting(Collections.emptyMap());
+  private final Configuration configuration = Configuration.createEmpty();
 
   // Transient fields
   @JsonIgnore
@@ -410,7 +410,7 @@ public class BlueprintV2Impl implements BlueprintV2 {
     @JsonProperty("blueprint_name")
     public String name;
     @JsonProperty("security")
-    public SecurityConfiguration securityConfiguration;
+    public SecurityConfiguration securityConfiguration = SecurityConfiguration.NONE;
 
     public Blueprints() { }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/94a93a6b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
index 123237f..27b9247 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
@@ -49,6 +49,10 @@ public class Configuration {
    */
   private Configuration parentConfiguration;
 
+  public static Configuration createEmpty() {
+    return new Configuration(new HashMap<>(0), new HashMap<>(0));
+  }
+
   public Configuration(Configuration config, Configuration parent) {
     this(config.getProperties(), config.getAttributes(), parent);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/94a93a6b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
index 7955169..7a8b8a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
@@ -31,6 +31,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  */
 public class SecurityConfiguration {
 
+  public static final SecurityConfiguration NONE = new SecurityConfiguration(SecurityType.NONE);
+
   /**
    * Security Type
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/94a93a6b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index e80396f..4a93ecd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -41,7 +41,7 @@ public class Service implements Configurable {
   private String stackId;
 
   @JsonIgnore
-  private Configuration configuration;
+  private Configuration configuration = Configuration.createEmpty();
 
   private Set<ServiceId> dependencies = ImmutableSet.of();
 


Mime
View raw message