diff --git a/RELEASE-NOTES.html b/RELEASE-NOTES.html
index 861f3188a..d58e865ac 100644
--- a/RELEASE-NOTES.html
+++ b/RELEASE-NOTES.html
@@ -65,6 +65,7 @@ If this causes major headaches to anyone please contact commons-dev at jakarta.a
BeanMap.initialize() - Internal variable now correctly initialised with only write methods that actually exist [15895]
TransformedMap.putAll - Now allows putAll of an empty map [34686]
AbstractHashedMap deserialization - Fix to prevent doubling of internal data array [34265]
+Flat3Map.equals() - Fix to make flat mode comparison actually work [34917]
JAVADOC
diff --git a/project.xml b/project.xml
index f55199cf7..986f96a10 100644
--- a/project.xml
+++ b/project.xml
@@ -245,6 +245,9 @@
Kasper Nielsen
+
+ Stanislaw Osinski
+
Alban Peignier
diff --git a/src/java/org/apache/commons/collections/map/Flat3Map.java b/src/java/org/apache/commons/collections/map/Flat3Map.java
index e64afc54d..18c38d518 100644
--- a/src/java/org/apache/commons/collections/map/Flat3Map.java
+++ b/src/java/org/apache/commons/collections/map/Flat3Map.java
@@ -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;
}
}
}
diff --git a/src/test/org/apache/commons/collections/map/TestFlat3Map.java b/src/test/org/apache/commons/collections/map/TestFlat3Map.java
index 89ae5f86d..437803075 100644
--- a/src/test/org/apache/commons/collections/map/TestFlat3Map.java
+++ b/src/test/org/apache/commons/collections/map/TestFlat3Map.java
@@ -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());