• Bug
  • Status: Open
  • 2 Major
  • Resolution:
  • interfaces
  • Reporter: teck
  • September 01, 2009
  • 0
  • Watchers: 3
  • December 16, 2011


If you allow SerializationTest to operate on ConcurrentHashMap it will fail with this NPE (line numbers correspond to sun jdk1.5.0_20):

java.lang.NullPointerException at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:256) at java.util.concurrent.ConcurrentHashMap$Segment.put(ConcurrentHashMap.java:408) at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:848) at java.util.concurrent.ConcurrentHashMap.readObject(ConcurrentHashMap.java:1412) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1812) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348) at com.tctest.SerializationTest.deserialize(SerializationTest.java:347)


Tim Eck 2009-09-01

This isn’t a new bug report. It is an updated version of DEV-219 (internal-only) with an updated stack trace

Tim Eck 2009-09-01

There is no known workaround other than avoiding ConcurrrentHashMap instances for serialized object graphs

Alex Miller 2009-09-02

Well the workaround might be to copy the data into a HashMap or other data structure before/after serialization.

Tim Eck 2009-09-02

That is a workaround someone can do in their app for sure. Are you suggesting that is something we could be doing internally to somehow make this work for users? I don’t see that

Alex Miller 2009-09-02

Not suggesting it as an internal fix, just that this might be possible in some cases (where the CHM is not buried in an object graph) as a temporary workaround.

Steve Harris 2009-09-09

Is this hard? If it is we can punt past santiago.

Alex Miller 2009-09-09

it’s not easy. :) until we determine full answer, hard to say whether medium or hard