The Collections Mysterious LRUMap NullPointerException

See Bug 32573

The Collections 3.1 LRUMap has been reported to throw unexpected NullPointerException's. What is mysterious is that these have only only ever been observed by a small number of users in production code. Attempts to replicate this phenomenum under laboratory conditions have (so far) failed.

This map (as with the majority of the maps, collections and bags in commons-collections) should be externally synchronized (by using - for example - Collections.synchronizeMap) when used in a multithreaded environment. When not appropriately synchronized, analysis of the code indicates that NullPointerExceptions may be thrown. However, all those who have analysed the code have yet to find a use case where a NullPointerException may be thrown when the map is appropriately synchronized.

So far, a definitive cause eludes us. It may be that this issue is caused by inappropriate synchronization or by problems with sychronization code in one or more JVMs. If you think you can help us solve this mystery, please email the commons developer list or edit this wiki page (at the bottom, if you please).

SOAK Tests

In order to try to discover whether this is a real issue but limited to certain environments (for example, only in particular JVMs or in multiprocessor machines), volunteers have run long running SOAK tests on various environment. The commons-collections team would be very grateful to anyone else who is willing to donate some cycles and record their results below.

Just to report that I have run the synchronized soak test using 5
threads and 10,000,000 loops on

AlphaServer 4X00 5/400 4MB, 4 CPUs

OpenVMS 7.3-1

java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition
Fast VM (build 1.4.0-1, build J2SDK.v.1.4.0:01/10/2003-09:47, native
threads, jit_140)

Just for the record, since everyone might not have access to these
platforms, I saw the same results as Phil while running SoakLRUMap
overnight on Mac OS X 10.4.3 dual-G4 and dual-G5 hardware with java
versions 1.4.2_09 and 1.5.0_05.

10 days running constantly on a Debian box using Sun JRE 1.5.0-04 without NPEs

Thanks to:

(Volunteers please feel free to append your name and record your results. The SOAK tests are attached to the bug.)

Solutions To The Mystery Below, Please

CollectionsMysteriousNullPointerException (last edited 2009-09-20 23:48:09 by localhost)