You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/10/02 12:49:58 UTC

[07/10] brooklyn-server git commit: MementosGenerator: fix use of deprecated code

MementosGenerator: fix use of deprecated code


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/af1396fa
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/af1396fa
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/af1396fa

Branch: refs/heads/master
Commit: af1396fa110ed02c31427ab62beae4139a336ba2
Parents: 4ac5db6
Author: Aled Sage <al...@gmail.com>
Authored: Tue Sep 26 13:21:01 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Oct 2 06:08:30 2017 +0100

----------------------------------------------------------------------
 .../core/mgmt/rebind/dto/MementosGenerators.java  |  5 ++---
 .../core/mgmt/rebind/RebindFailuresTest.java      | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/af1396fa/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
index 1b0700f..5b73079 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementosGenerators.java
@@ -148,9 +148,8 @@ public class MementosGenerators {
             builder.configUnmatched.put(key, value); 
         }
         
-        @SuppressWarnings("rawtypes")
-        Map<AttributeSensor, Object> allAttributes = entity.getAllAttributes();
-        for (@SuppressWarnings("rawtypes") Map.Entry<AttributeSensor, Object> entry : allAttributes.entrySet()) {
+        Map<AttributeSensor<?>, Object> allAttributes = entity.sensors().getAll();
+        for (Map.Entry<AttributeSensor<?>, Object> entry : allAttributes.entrySet()) {
             AttributeSensor<?> key = checkNotNull(entry.getKey(), allAttributes);
             if (key.getPersistenceMode() != SensorPersistenceMode.NONE) {
                 Object value = entry.getValue();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/af1396fa/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java
index 00c3432..f056a22 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindFailuresTest.java
@@ -257,14 +257,18 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
         @SetFromFlag("failOnRebind")
         public static final ConfigKey<Boolean> FAIL_ON_REBIND = ConfigKeys.newBooleanConfigKey("failOnRebind", "Whether to throw exception when rebinding", false);
         
-        @SuppressWarnings("rawtypes")
         @Override
-        public Map<AttributeSensor, Object> getAllAttributes() {
-            if (Boolean.TRUE.equals(getConfig(FAIL_ON_GENERATE_MEMENTO))) {
-                throw new RuntimeException("Simulating failure in "+this+", which will cause memento-generation to fail");
-            } else {
-                return super.getAllAttributes();
-            }
+        public BasicSensorSupport sensors() {
+            return new BasicSensorSupport() {
+                @Override
+                public Map<AttributeSensor<?>, Object> getAll() {
+                    if (Boolean.TRUE.equals(getConfig(FAIL_ON_GENERATE_MEMENTO))) {
+                        throw new RuntimeException("Simulating failure in "+this+", which will cause memento-generation to fail");
+                    } else {
+                        return super.getAll();
+                    }
+                }
+            };
         }
         
         @Override