cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikita Timofeev <ntimof...@objectstyle.com>
Subject Re: Race Condition in o.a.c.u.ReferenceMap.values() Causing NPE in ObjectStore.objectsInState(int)
Date Thu, 16 Nov 2017 11:17:19 GMT
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 <djfeshbach@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

Mime
View raw message