From ed3d9ab90be17fcf527b79ba140d5b5dae5c4310 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 10 Feb 2011 23:57:59 +0000 Subject: [PATCH] [COLLECTIONS-330] javadoc: add warning about calling get() while iterating git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1069624 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/commons/collections/map/LRUMap.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/java/org/apache/commons/collections/map/LRUMap.java b/src/java/org/apache/commons/collections/map/LRUMap.java index 581266537..6e3fbf0bd 100644 --- a/src/java/org/apache/commons/collections/map/LRUMap.java +++ b/src/java/org/apache/commons/collections/map/LRUMap.java @@ -23,6 +23,7 @@ import java.io.Serializable; import java.util.Map; import org.apache.commons.collections.BoundedMap; +import org.apache.commons.collections.MapIterator; /** * A Map implementation with a fixed maximum size which removes @@ -33,6 +34,13 @@ import org.apache.commons.collections.BoundedMap; * change the order. Queries such as containsKey and containsValue or access * via views also do not change the order. *

+ * A somewhat subtle ramification of the least recently used + * algorithm is that calls to {@link #get(Object)} stand a very good chance + * of modifying the map's iteration order and thus invalidating any + * iterators currently in use. It is therefore suggested that iterations + * over an {@link LRUMap} instance access entry values only through a + * {@link MapIterator} or {@link #entrySet()} iterator. + *

* The map implements OrderedMap and entries may be queried using * the bidirectional OrderedMapIterator. The order returned is * least recently used to most recently used. Iterators from map views can