You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2013/03/06 22:57:53 UTC
svn commit: r1453585 - in /commons/proper/collections/trunk/src:
main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java
test/java/org/apache/commons/collections/map/AbstractMapTest.java
Author: tn
Date: Wed Mar 6 21:57:53 2013
New Revision: 1453585
URL: http://svn.apache.org/r1453585
Log:
[COLLECTIONS-445] Several workarounds for IBM JDKs flawed TreeMap.
Modified:
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java?rev=1453585&r1=1453584&r2=1453585&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualTreeBidiMap.java Wed Mar 6 21:57:53 2013
@@ -362,7 +362,11 @@ public class DualTreeBidiMap<K, V> exten
throw new IllegalArgumentException(
"Cannot use setValue() when the object being set is already in the map");
}
- return parent.put(last.getKey(), value);
+ final V oldValue = parent.put(last.getKey(), value);
+ // set also the value in the Map.Entry:
+ // due to a bug in IBM JDK where the Entry is not in sync with the underlying map
+ last.setValue(value);
+ return oldValue;
}
public void reset() {
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java?rev=1453585&r1=1453584&r2=1453585&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/AbstractMapTest.java Wed Mar 6 21:57:53 2013
@@ -1921,7 +1921,8 @@ public abstract class AbstractMapTest<K,
*/
private void views() {
this.keySet = getMap().keySet();
- this.values = getMap().values();
+ // see verifyValues: retrieve the values collection only when verifying them
+ // this.values = getMap().values();
this.entrySet = getMap().entrySet();
}
@@ -1999,6 +2000,13 @@ public abstract class AbstractMapTest<K,
public void verifyValues() {
final List<V> known = new ArrayList<V>(getConfirmed().values());
+
+ // bug in IBM JDK: IBM J9 VM build 2.4, JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr12-20121024_126067
+ // a call to values() on an empty map retrieved via TreeMap#headMap or tailMap
+ // will render the values view unusable: resulting in NullPointExceptions or missing values
+ // it will also not recover, as the value view is cached internally
+ values = getMap().values();
+
final List<V> test = new ArrayList<V>(values);
final int size = getConfirmed().size();