Backport COLLECTIONS-334 to 3.2.2. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713294 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/d75768a4 Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/d75768a4 Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/d75768a4 Branch: refs/heads/COLLECTIONS_3_2_X Commit: d75768a4b2e71f88bf47ee45163fd671bebbd7e3 Parents: 6a7d35d Author: Thomas Neidhart <t...@apache.org> Authored: Sun Nov 8 21:07:13 2015 +0000 Committer: Thomas Neidhart <t...@apache.org> Committed: Sun Nov 8 21:07:13 2015 +0000 ---------------------------------------------------------------------- src/changes/changes.xml | 6 +++--- .../org/apache/commons/collections/map/StaticBucketMap.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-collections/blob/d75768a4/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9d3a1b7..053ccc5 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -35,6 +35,9 @@ <action issue="COLLECTIONS-335" dev="jochen" type="fix" due-to="sebb"> Fixed cache assignment for "TreeBidiMap#entrySet". </action> + <action issue="COLLECTIONS-334" dev="jochen" type="fix" due-to="sebb"> + Synchronized access to lock in "StaticBucketMap#size()". + </action> <action issue="COLLECTIONS-294" dev="bayard" type="fix" due-to="Benjamin Bentmann"> "CaseInsensitiveMap" will now convert input strings to lower-case in a locale-independent manner. @@ -76,9 +79,6 @@ "ListUtils#intersection(List, List)" will now also work correctly if there are duplicate elements in the provided lists. </action> - <action issue="COLLECTIONS-334" dev="jochen" type="fix" due-to="sebb"> - Synchronized access to lock in "StaticBucketMap#size()". - </action> <action issue="COLLECTIONS-330" dev="mbenson" type="fix" due-to="Joerg Schaible"> "LRUMap#keySet()#remove(Object)" will not throw a "ConcurrentModificationException" anymore. </action> http://git-wip-us.apache.org/repos/asf/commons-collections/blob/d75768a4/src/java/org/apache/commons/collections/map/StaticBucketMap.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/commons/collections/map/StaticBucketMap.java b/src/java/org/apache/commons/collections/map/StaticBucketMap.java index 4a130c3..1a0d379 100644 --- a/src/java/org/apache/commons/collections/map/StaticBucketMap.java +++ b/src/java/org/apache/commons/collections/map/StaticBucketMap.java @@ -182,7 +182,9 @@ public final class StaticBucketMap implements Map { int cnt = 0; for (int i = 0; i < buckets.length; i++) { - cnt += locks[i].size; + synchronized(locks[i]) { + cnt += locks[i].size; + } } return cnt; }