This is in 4.1.M1 The stack trace is pretty short: java.lang.NullPointerException at org.apache.cayenne.access.ObjectStore.objectsInState(ObjectStore.java:520) at org.apache.cayenne.access.DataContext.newObjects(DataContext.java:242) ...
The problem is in ReferenceMap.values(). If the GC runs between checkReferenceQueue() and the last v.get(), then null can be added to the collection (when using the default WeakValueMap). keySet() and entrySet() have similar issues. I tried simply adding a check to exclude nulls from the collection, but I get a test failure in WeakValueMapTest.testMapConstructor() because it expects (a weak reference to) null to stay in the map. What's the proper behavior here? Should weak mappings really allow null? I'm surprised you're even allowed to create a reference with a null referent. Thanks, David