jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
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 GMT
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;
     }



Mime
View raw message