From 09e7a4b86e885aaf1e9528416b01c6e84e7f82b8 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 9 May 2002 03:10:46 +0000 Subject: [PATCH] Fixed to ensure that get(Object) won't add a mapping to a null value when one didn't exist before. That is, if containsKey(foo) returns false, then get(foo) will not change that. Added serial version UID to maintain backwards compatibility. The auto generated serialization UID differs from the released version because of the addition of a new method. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130699 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/collections/LRUMap.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/commons/collections/LRUMap.java b/src/java/org/apache/commons/collections/LRUMap.java index 02eacf7a7..d584c9a2d 100644 --- a/src/java/org/apache/commons/collections/LRUMap.java +++ b/src/java/org/apache/commons/collections/LRUMap.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/LRUMap.java,v 1.14 2002/05/08 18:11:36 morgand Exp $ - * $Revision: 1.14 $ - * $Date: 2002/05/08 18:11:36 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/LRUMap.java,v 1.15 2002/05/09 03:10:46 mas Exp $ + * $Revision: 1.15 $ + * $Date: 2002/05/09 03:10:46 $ * * ==================================================================== * @@ -131,6 +131,8 @@ public class LRUMap extends SequencedHashMap implements Externalizable { * null value or if the key has no value. */ public Object get(Object key) { + if(!containsKey(key)) return null; + Object value = remove(key); super.put(key,value); return value; @@ -240,5 +242,9 @@ public class LRUMap extends SequencedHashMap implements Externalizable { removeLRU(); } } - + + + // add a serial version uid, so that if we change things in the future + // without changing the format, we can still deserialize properly. + private static final long serialVersionUID = 2197433140769957051L; }