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/24 12:40:05 UTC
[23/39] ambari git commit: AMBARI-22297. Simplify getWithEmptyDefault
using computeIfAbsent (adoroszlai)
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/71508624
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/71508624
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/71508624
Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: 71508624f9d0f83d2443a6e6cd8cbfb6b366f415
Parents: e6b0f51
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Fri Nov 17 10:26:55 2017 +0100
Committer: Doroszlai, Attila <ad...@hortonworks.com>
Committed: Fri Nov 24 13:30:45 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/71508624/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/71508624/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?
}
}