brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/2] brooklyn-server git commit: BROOKLYN-461: fix CollectionMerger’s Ref.equals
Date Tue, 11 Apr 2017 11:33:00 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 5b24a9f4e -> 486246510


BROOKLYN-461: fix CollectionMerger’s Ref.equals


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

Branch: refs/heads/master
Commit: 8c95a0a1d3f03901d2d25c6c97379e9e39259897
Parents: 9557540
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Apr 11 10:26:17 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Apr 11 10:33:40 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/util/collections/CollectionMerger.java    |  2 +-
 .../util/collections/CollectionMergerTest.java         | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8c95a0a1/utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionMerger.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionMerger.java
b/utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionMerger.java
index c9baac0..c7e1742 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionMerger.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/collections/CollectionMerger.java
@@ -199,7 +199,7 @@ public class CollectionMerger {
                 if (!(o instanceof Ref)) {
                     return false;
                 }
-                return ((Ref)o).obj == ((Ref)o).obj;
+                return obj == ((Ref)o).obj;
             }
             
             @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8c95a0a1/utils/common/src/test/java/org/apache/brooklyn/util/collections/CollectionMergerTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/collections/CollectionMergerTest.java
b/utils/common/src/test/java/org/apache/brooklyn/util/collections/CollectionMergerTest.java
index 7ff7bba..f8b4f05 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/collections/CollectionMergerTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/collections/CollectionMergerTest.java
@@ -19,6 +19,7 @@
 package org.apache.brooklyn.util.collections;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
 
 import java.io.StringReader;
 import java.util.Map;
@@ -403,6 +404,18 @@ public class CollectionMergerTest {
         assertEquals(resultShallow, resultDepth1);
     }
 
+    @Test
+    public void testRefEquals() {
+        String val = new String("a"); // using `new` to ensure it really is a new object
+        String val2 = new String("a");
+        CollectionMerger.Visited.Ref ref1 = new CollectionMerger.Visited.Ref(val);
+        CollectionMerger.Visited.Ref ref1b = new CollectionMerger.Visited.Ref(val);
+        CollectionMerger.Visited.Ref ref2 = new CollectionMerger.Visited.Ref(val2);
+        
+        assertEquals(ref1, ref1b);
+        assertNotEquals(ref1, ref2);
+    }
+    
     protected Iterable<?> parseYaml(String yaml) {
         return new Yaml().loadAll(new StringReader(yaml));
     }


Mime
View raw message