Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 32FE5200D3E for ; Thu, 16 Nov 2017 12:17:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 318D6160BE6; Thu, 16 Nov 2017 11:17:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 78601160BE5 for ; Thu, 16 Nov 2017 12:17:45 +0100 (CET) Received: (qmail 91065 invoked by uid 500); 16 Nov 2017 11:17:44 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 91043 invoked by uid 99); 16 Nov 2017 11:17:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2017 11:17:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 03437C1B52 for ; Thu, 16 Nov 2017 11:17:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.944 X-Spam-Level: * X-Spam-Status: No, score=1.944 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, GAPPY_SUBJECT=1.312, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=objectstyle-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Mf2DAVrze-SO for ; Thu, 16 Nov 2017 11:17:41 +0000 (UTC) Received: from mail-it0-f51.google.com (mail-it0-f51.google.com [209.85.214.51]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 2EBAE5FBB1 for ; Thu, 16 Nov 2017 11:17:41 +0000 (UTC) Received: by mail-it0-f51.google.com with SMTP id y15so5494401ita.4 for ; Thu, 16 Nov 2017 03:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=objectstyle-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=MAQaBMhJt0c4Yy9MeOh7tV+6ATn3bbriSgnuM2GGQ30=; b=vJUVX+E+DzMeMg2XdNWsY4pJDOVJUuIOgfu67SThbCQhKEK9IrKUQKXRQsOp0kShPD Ep5QSK7GDFbzXULpw8fRFOHxKBrn0i6E0GhsTKoq+i83GECj42YMqXlCBxkzxCs1Q/Ag /hJ96yQFYoyYHjIa0jXyy+2K3bPqYhVH3mK7DUEyueo6WL3GWh7OR1PvWLVpWdtFYUHL PhegAbfcNcPpmzdhXk/4Yz+d73mFzwh2JIzDxYp+t+yQswAX8hXFdmfhCp8Jsvin+lTU aNkre8N97FlfbP0c+kHVHX6lVrZDJYjzIAPLJ5+tKFT3IoYbWxQdYPaFmG4OgoWdsyr7 kVZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=MAQaBMhJt0c4Yy9MeOh7tV+6ATn3bbriSgnuM2GGQ30=; b=pg+zli8I+TCYbfmI45Iz/3+nOGg2DKJNfP+iG9TpfQ2vOOxdSP9rQmNpyzaDOBPyiQ 3SWJMhpm6oF/CX3MmyegdCslQYwOTVZqkjoClrNxPBgY6F72huZowx9QsWj8P3/qs3om 27UIGHOl7Tb8zmfP/a/hI8EQj/nR7WCwZJRqIx2vWfzn1HDEc2w32Zva5J8vlEL2Ypun bK0a90whNhGdTIuj7kYUIp1eKXhGN86YJBDLu+S1eox3sSTTiDX6yKSCo5+D4+fSmelw kygMFeVdEmVJuS3rn+QP4j5IZvkEYqwYp7+UDhT8PMQVObeDGWhB5iYMvmrOyWtY974T U6yw== X-Gm-Message-State: AJaThX4LtHUKZOd0fpPWsjwem7Q3mn+TeMMZ/uAmBX0EN+BzmOOU9T7M is0+savstY1xIo6QsZxXeo+SFzUedinNA4ruPrr7HYZ8 X-Google-Smtp-Source: AGs4zMbvWVyJYFRNOAwokFFBIOfIPy4XcZWgHS30ynI+8qvYzlYbGesXb0bn7pSOUNEZIlohupq33jUcrWn9NHyQ90A= X-Received: by 10.36.221.216 with SMTP id t207mr1776604itf.112.1510831059716; Thu, 16 Nov 2017 03:17:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.151.171 with HTTP; Thu, 16 Nov 2017 03:17:19 -0800 (PST) In-Reply-To: References: From: Nikita Timofeev Date: Thu, 16 Nov 2017 14:17:19 +0300 Message-ID: Subject: Re: Race Condition in o.a.c.u.ReferenceMap.values() Causing NPE in ObjectStore.objectsInState(int) To: dev@cayenne.apache.org Content-Type: text/plain; charset="UTF-8" archived-at: Thu, 16 Nov 2017 11:17:46 -0000 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 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