felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1782547 - in /felix/trunk/osgi-r7/configadmin/src: main/java/org/apache/felix/cm/impl/ConfigurationImpl.java test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java
Date Sat, 11 Feb 2017 00:29:45 GMT
Author: davidb
Date: Sat Feb 11 00:29:45 2017
New Revision: 1782547

URL: http://svn.apache.org/viewvc?rev=1782547&view=rev
Log:
ConfigurationImpl.equals ensures that null is not equals to an empty map.

Modified:
    felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
    felix/trunk/osgi-r7/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java

Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java?rev=1782547&r1=1782546&r2=1782547&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
Sat Feb 11 00:29:45 2017
@@ -678,6 +678,16 @@ public class ConfigurationImpl extends C
      */
     static boolean equals( Dictionary<String, Object> props1, Dictionary<String,
Object> props2)
     {
+        if (props1 == null) {
+            if (props2 == null) {
+                return true;
+            } else {
+                return false;
+            }
+        } else if (props2 == null) {
+            return false;
+        }
+
         final int count1 = getCount(props1);
         final int count2 = getCount(props2);
         if ( count1 != count2 )

Modified: felix/trunk/osgi-r7/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java?rev=1782547&r1=1782546&r2=1782547&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationImplTest.java
Sat Feb 11 00:29:45 2017
@@ -18,13 +18,14 @@
  */
 package org.apache.felix.cm.impl;
 
-import static org.junit.Assert.assertTrue;
-
 import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 public class ConfigurationImplTest {
 
     @Test public void testEqualsWithArrays() {
@@ -38,5 +39,21 @@ public class ConfigurationImplTest {
 
         props2.put("array", new Long[] {1L,2L});
         assertTrue(ConfigurationImpl.equals(props1, props2));
+
+        final Dictionary<String, Object> props3 = new Hashtable<String, Object>();
+        props3.put("array", new long[] {1,2,3});
+        assertFalse(ConfigurationImpl.equals(props1, props3));
+
+        final Dictionary<String, Object> props4 = new Hashtable<String, Object>();
+        props3.put("array", new long[] {1});
+        assertFalse(ConfigurationImpl.equals(props1, props4));
+    }
+
+    @Test public void testEqualsForNull() {
+        final Dictionary<String, Object> props = new Hashtable<String, Object>();
+        assertFalse(ConfigurationImpl.equals(props, null));
+        assertFalse(ConfigurationImpl.equals(null, props));
+        assertTrue(ConfigurationImpl.equals(null, null));
+
     }
 }



Mime
View raw message