Hi David, Thanks for this issue, I've made a fix for it. See Jira ticket for details [1]. Basically I've made what you suggested, i.e. forbid null references in this map.
[1] https://issues.apache.org/jira/browse/CAY-2380 On Fri, Nov 10, 2017 at 8:15 PM, David Feshbach <djfeshb...@gmail.com> wrote: > 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 -- Best regards, Nikita Timofeev