Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 36465 invoked from network); 24 Apr 2008 17:52:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Apr 2008 17:52:36 -0000 Received: (qmail 47333 invoked by uid 500); 24 Apr 2008 17:52:30 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 47305 invoked by uid 500); 24 Apr 2008 17:52:30 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 47294 invoked by uid 99); 24 Apr 2008 17:52:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 10:52:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jukka.zitting@gmail.com designates 74.125.46.28 as permitted sender) Received: from [74.125.46.28] (HELO yw-out-2324.google.com) (74.125.46.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 17:51:46 +0000 Received: by yw-out-2324.google.com with SMTP id 5so361459ywh.1 for ; Thu, 24 Apr 2008 10:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=MIh2mDF435xLgrFJbukqbsQk4FazzNt/KXPu6XnBlPY=; b=she7PEQxEQXQQQagOQvo/7jyXvjm1+TgKoe4WFxDyRVBa+ZEagYpBObvWk6/gjBH66w+xT5nFN1dLi3uXpWsAVV1uJ4asTiZkDQsia6ZvvkeaWDWM3W/OURDDUeLLH7Yg6KHOn8iYHTMAKqYSwY8amBD7EHcNYi26n2sMM6UDpI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=eie2lTUHuEQDnTPyF604p/vLZUdRreohkxXUxQcSs2lXXq9/54g/iKa+2WK7cqaSlI1mSjk0yOMjCFhn9SequzGAzIh4GZ4+Va1K23w5/8WLuBukER2kYh6/0vvvJmfvHQ7jK+yZdW0Prk8gEKagf3FXJwM0lIjK63Hupv45bq4= Received: by 10.142.47.6 with SMTP id u6mr337362wfu.29.1209059513729; Thu, 24 Apr 2008 10:51:53 -0700 (PDT) Received: by 10.142.126.3 with HTTP; Thu, 24 Apr 2008 10:51:53 -0700 (PDT) Message-ID: <510143ac0804241051y5e886d01v86657b3db354bcc7@mail.gmail.com> Date: Thu, 24 Apr 2008 20:51:53 +0300 From: "Jukka Zitting" To: dev@jackrabbit.apache.org Subject: Re: Concurrent addNode (Was: [jira] Commented: (JCR-1552) Concurrent conflicting property creation sometimes doesn't fail) In-Reply-To: <5f211bd50804241041o6d81e20fmb3b64f5d2ac669f9@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <510143ac0804241029g514e2c5eqa9a5fd312df17233@mail.gmail.com> <5f211bd50804241041o6d81e20fmb3b64f5d2ac669f9@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi, On Thu, Apr 24, 2008 at 8:41 PM, Thomas Mueller wrote: > > The best solution IMHO is not to allow SNS in the first place. > > Yes, unfortunately it's not the default behavior. And making it the > default would break XML import. Sure, but if you're (or your application is) concerned about this, it's fairly easy to disable SNSs. > > Another solution would be a custom getOrAddNode() method, like the one > > I've implemented > > try { > return parent.getNode(name); > } catch (PathNotFoundException e) { > return parent.addNode(name, type); > } > > Uhm, looks a bit ugly, and still doesn't always work with multiple > threads (two threads can't get the node, both will create one)? Or do > you mean something else? Sure, it's not as nice as it could be, but it works in practice. I'm using this in a non-SNS case (nt:folder), so the worst that can happen is the addNode (or the following save) failing with an InvalidItemStateException. And that's fine as those cases are quite rare (reasonable naming) and the surrounding application (email) will just automatically retry the operation a bit later. I could have used a JCR lock for this, but in this case the benefit is not necessarily worth the trouble. > It's probably a bit late to add an atomic getOrAddNode into JSR-283 I > guess... But we could add it to the Jackrabbit API anyway if we want > to. We already provide the locking mechanism for clients that care about such things, so perhaps a utility mechanism in jcr-commons would be more appropriate. BR, Jukka Zitting