Fix Flat3Map.equals to actually work
bug 34917, from Stanislaw Osinski git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@170210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e52c4c50e1
commit
f95865f481
|
@ -65,6 +65,7 @@ If this causes major headaches to anyone please contact commons-dev at jakarta.a
|
|||
<li>BeanMap.initialize() - Internal variable now correctly initialised with only write methods that actually exist [15895]</li>
|
||||
<li>TransformedMap.putAll - Now allows putAll of an empty map [34686]</li>
|
||||
<li>AbstractHashedMap deserialization - Fix to prevent doubling of internal data array [34265]</li>
|
||||
<li>Flat3Map.equals() - Fix to make flat mode comparison actually work [34917]</li>
|
||||
</ul>
|
||||
|
||||
<center><h3>JAVADOC</h3></center>
|
||||
|
|
|
@ -245,6 +245,9 @@
|
|||
<contributor>
|
||||
<name>Kasper Nielsen</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Stanislaw Osinski</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Alban Peignier</name>
|
||||
</contributor>
|
||||
|
|
|
@ -1041,24 +1041,27 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable {
|
|||
switch (size) { // drop through
|
||||
case 3:
|
||||
if (other.containsKey(key3) == false) {
|
||||
otherValue = other.get(key3);
|
||||
if (value3 == null ? otherValue != null : !value3.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
otherValue = other.get(key3);
|
||||
if (value3 == null ? otherValue != null : !value3.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
case 2:
|
||||
if (other.containsKey(key2) == false) {
|
||||
otherValue = other.get(key2);
|
||||
if (value2 == null ? otherValue != null : !value2.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
otherValue = other.get(key2);
|
||||
if (value2 == null ? otherValue != null : !value2.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
case 1:
|
||||
if (other.containsKey(key1) == false) {
|
||||
otherValue = other.get(key1);
|
||||
if (value1 == null ? otherValue != null : !value1.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
otherValue = other.get(key1);
|
||||
if (value1 == null ? otherValue != null : !value1.equals(otherValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,26 @@ public class TestFlat3Map extends AbstractTestIterableMap {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testEquals1() {
|
||||
Flat3Map map1 = new Flat3Map();
|
||||
map1.put("a", "testA");
|
||||
map1.put("b", "testB");
|
||||
Flat3Map map2 = new Flat3Map();
|
||||
map2.put("a", "testB");
|
||||
map2.put("b", "testA");
|
||||
assertEquals(false, map1.equals(map2));
|
||||
}
|
||||
|
||||
public void testEquals2() {
|
||||
Flat3Map map1 = new Flat3Map();
|
||||
map1.put("a", "testA");
|
||||
map1.put("b", "testB");
|
||||
Flat3Map map2 = new Flat3Map();
|
||||
map2.put("a", "testB");
|
||||
map2.put("c", "testA");
|
||||
assertEquals(false, map1.equals(map2));
|
||||
}
|
||||
|
||||
public void testClone2() {
|
||||
Flat3Map map = new Flat3Map();
|
||||
assertEquals(0, map.size());
|
||||
|
|
Loading…
Reference in New Issue