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 2017/11/17 09:27:22 UTC
ambari git commit: AMBARI-22297. Simplify getWithEmptyDefault using
computeIfAbsent (adoroszlai)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-14714-blueprintv2 35834d5f9 -> 7a7766115
AMBARI-22297. Simplify getWithEmptyDefault using computeIfAbsent (adoroszlai)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7a776611
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7a776611
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7a776611
Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: 7a776611550f00241f7a227b69500d40dcc427f5
Parents: 35834d5
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Fri Nov 17 10:26:55 2017 +0100
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Fri Nov 17 10:26:55 2017 +0100
----------------------------------------------------------------------
.../java/org/apache/ambari/server/controller/StackV2.java | 7 +------
.../java/org/apache/ambari/server/topology/Configurable.java | 2 +-
2 files changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7a776611/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 0b0329c..9bdd6a6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -516,12 +516,7 @@ public class StackV2 {
}
static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) {
- Map<IK, IV> innerMap = outerMap.get(outerKey);
- if (null == innerMap) {
- innerMap = new HashMap<>();
- outerMap.put(outerKey, innerMap);
- }
- return innerMap;
+ return outerMap.computeIfAbsent(outerKey, __ -> new HashMap<>());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7a776611/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
index 0f3cf17..bab7da6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
@@ -49,7 +49,7 @@ public interface Configurable {
if (null != getConfiguration()) {
configAsMap.put("properties", getConfiguration().getProperties());
}
- return Lists.newArrayList(configAsMap);
+ return Lists.newArrayList(configAsMap); // TODO replace with Collections.singletonList?
}
}