Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 98151 invoked from network); 10 Aug 2009 08:24:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Aug 2009 08:24:29 -0000 Received: (qmail 62112 invoked by uid 500); 10 Aug 2009 08:24:36 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 62019 invoked by uid 500); 10 Aug 2009 08:24:36 -0000 Mailing-List: contact commits-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 commits@jackrabbit.apache.org Received: (qmail 62010 invoked by uid 99); 10 Aug 2009 08:24:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Aug 2009 08:24:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Aug 2009 08:24:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 076E8238889C; Mon, 10 Aug 2009 08:24:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r802690 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java Date: Mon, 10 Aug 2009 08:24:13 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090810082414.076E8238889C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mreutegg Date: Mon Aug 10 08:24:13 2009 New Revision: 802690 URL: http://svn.apache.org/viewvc?rev=802690&view=rev Log: JCR-2238: Binary throws NullPointerException - use synchronized instead of AtomicInteger Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java?rev=802690&r1=802689&r2=802690&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/RefCountingBLOBFileValue.java Mon Aug 10 08:24:13 2009 @@ -17,7 +17,6 @@ package org.apache.jackrabbit.core.value; import java.io.InputStream; -import java.util.concurrent.atomic.AtomicInteger; import javax.jcr.RepositoryException; @@ -48,7 +47,7 @@ /** * The current ref count. Initially set to one. */ - private final AtomicInteger refCount = new AtomicInteger(1); + private int refCount = 1; /** * Whether this instance has been discarded and cannot be used anymore. @@ -70,9 +69,9 @@ /** * Discards the underyling value if the reference count drops to zero. */ - public void dispose() { - if (refCount.get() > 0) { - if (refCount.decrementAndGet() == 0) { + public synchronized void dispose() { + if (refCount > 0) { + if (--refCount == 0) { log.debug("{}@refCount={}, discarding value...", System.identityHashCode(this), refCount); value.dispose(); @@ -101,12 +100,12 @@ * @throws RepositoryException if an error occurs while creating the copy or * if this value has been disposed already. */ - BLOBFileValue copy() throws RepositoryException { - if (refCount.get() <= 0) { + synchronized BLOBFileValue copy() throws RepositoryException { + if (refCount <= 0) { throw new RepositoryException("this BLOBFileValue has been disposed"); } BLOBFileValue bin = new RefCountBinary(); - refCount.incrementAndGet(); + refCount++; log.debug("{}@refCount={}", System.identityHashCode(this), refCount); return bin; }