• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-core
  • asingh
  • Reporter: vlk
  • November 16, 2009
  • 0
  • Watchers: 1
  • January 15, 2010
  • November 19, 2009

Attachments

Description

Hello,

I've recently upgrade IBM WebSphere from version 7.0.0.5 to 7.0.0.7. In new version of WebSphere there was changed JVM class  LinkedHashMap.

In version 7.0.0.5 method put(key, value) works like : 1.) put entry into map 2.) execute removeEldestEntry(Map.Entry eldest) 3.) return value

Now it works in this way ( very simlified ) : 1.) insert key with value == null into map y = map.put(key, null) 2.) execute removeEldestEntry(Map.Entry eldest) 3.) map.put(key, value) 4.) return y

When cache is initialized, then removeEldestEntry(Map.Entry eldest) is called with eldest.getValue() == null. So it causes NullPointerException during initialization.

Caused by: java.lang.NullPointerException at net.sf.ehcache.store.LruMemoryStore$SpoolingLinkedHashMap.removeLeastRecentlyUsedElement(LruMemoryStore.java:200) at net.sf.ehcache.store.LruMemoryStore$SpoolingLinkedHashMap.removeEldestEntry(LruMemoryStore.java:189) at java.util.LinkedHashMap.putImpl(LinkedHashMap.java:409) at java.util.LinkedHashMap.put(LinkedHashMap.java:370) at net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:107) at net.sf.ehcache.Cache.put(Cache.java:693) at net.sf.ehcache.Cache.put(Cache.java:632) at org.hibernate.cache.EhCache.put(EhCache.java:119)

Version Identification : vlk@tx03 ~ $ /opt/IBM/WebSphere/AppServer/java/bin/java -version java version “1.6.0” Java(TM) SE Runtime Environment (build pxi3260sr6ifix-20091015_01(SR6+152211+155930+156106)) IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr6-20091001_43491 (JIT enabled, AOT enabled) J9VM - 20091001_043491 JIT - r9_20090902_1330ifx1 GC - 20090817_AA) JCL - 20091006_01

I try to repair this issue with attached patch-file.

Comments

Abhishek Singh 2009-11-19

Fixed.

Added null check to avoid NPE.