From 6e8951ed0325abe3e07e32aded0b27aacdbc1011 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Wed, 11 Oct 2017 20:27:25 +1300 Subject: [PATCH] COLLECTIONS-661: fix for concurrency issue in HashSetValuedHashMapTest --- src/changes/changes.xml | 3 +++ .../multimap/AbstractMultiValuedMapTest.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index cbe01cef4f..118df353a6 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -21,6 +21,9 @@ + + Intermittent test failures in Windows for HashSetValuedHashMap + Uncomment test in AbstractMapTest regarding LRUMap equals diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java index 1faaaa7949..b578459602 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -1086,7 +1086,10 @@ public K[] getSampleKeys() { @Override @SuppressWarnings("unchecked") public Collection[] getSampleValues() { - boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; + // Calling getMap() instead of makeObject() would make more sense, but due to concurrency + // issues, this may lead to intermittent issues. See COLLECTIONS-661. A better solution + // would be to re-design the tests, or add a boolean method to the parent. + boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues(); Collection[] colArr = new Collection[3]; for(int i = 0; i < 3; i++) { @@ -1099,7 +1102,9 @@ public Collection[] getSampleValues() { @Override @SuppressWarnings("unchecked") public Collection[] getNewSampleValues() { - boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; + // See comment in getSampleValues() to understand why we are calling makeObject() and not + // getMap(). See COLLECTIONS-661 for more. + boolean isSetValuedMap = AbstractMultiValuedMapTest.this.makeObject() instanceof SetValuedMap; Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" }; Collection[] colArr = new Collection[3]; for (int i = 0; i < 3; i++) {