jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r478641 - in /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version: InternalVersionImpl.java VersionManagerImpl.java XAVersionManager.java
Date Thu, 23 Nov 2006 19:04:36 GMT
Author: jukka
Date: Thu Nov 23 11:04:35 2006
New Revision: 478641

URL: http://svn.apache.org/viewvc?view=rev&rev=478641
Log:
JCR-546: Consistently use the try-finally pattern for acquiring locks

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java?view=diff&rev=478641&r1=478640&r2=478641
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
Thu Nov 23 11:04:35 2006
@@ -129,8 +129,8 @@
      * {@inheritDoc}
      */
     public InternalVersion[] getSuccessors() {
+        vMgr.acquireReadLock();
         try {
-            vMgr.acquireReadLock();
             InternalValue[] values = node.getPropertyValues(QName.JCR_SUCCESSORS);
             if (values != null) {
                 InternalVersion[] versions = new InternalVersion[values.length];

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?view=diff&rev=478641&r1=478640&r2=478641
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Thu Nov 23 11:04:35 2006
@@ -239,8 +239,8 @@
         if (id.equals(getHistoryRootId())) {
             return null;
         }
+        acquireReadLock();
         try {
-            acquireReadLock();
             synchronized (versionItems) {
                 InternalVersionItem item = (InternalVersionItem) versionItems.get(id);
                 if (item == null) {
@@ -397,8 +397,11 @@
     protected void itemDiscarded(InternalVersionItem item) {
         // evict removed item from cache
         acquireReadLock();
-        versionItems.remove(item.getId());
-        releaseReadLock();
+        try {
+            versionItems.remove(item.getId());
+        } finally {
+            releaseReadLock();
+        }
     }
 
     /**
@@ -440,11 +443,10 @@
             NodeReferences refs = pMgr.load(new NodeReferencesId(item.getId()));
             return refs.getReferences();
         } catch (ItemStateException e) {
-            // ignore
+            return Collections.EMPTY_LIST;
         } finally {
             releaseReadLock();
         }
-        return Collections.EMPTY_LIST;
     }
 
     /**
@@ -485,8 +487,11 @@
     public void stateDestroyed(ItemState destroyed) {
         // evict removed item from cache
         acquireReadLock();
-        versionItems.remove(destroyed.getId());
-        releaseReadLock();
+        try {
+            versionItems.remove(destroyed.getId());
+        } finally {
+            releaseReadLock();
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java?view=diff&rev=478641&r1=478640&r2=478641
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/XAVersionManager.java
Thu Nov 23 11:04:35 2006
@@ -524,18 +524,16 @@
      */
     private InternalVersionHistoryImpl makeLocalCopy(InternalVersionHistoryImpl history)
             throws RepositoryException {
-
-        NodeState state;
         acquireReadLock();
         try {
-            state = (NodeState) stateMgr.getItemState(history.getId());
+            NodeState state = (NodeState) stateMgr.getItemState(history.getId());
+            NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
+            return new InternalVersionHistoryImpl(this, stateEx);
         } catch (ItemStateException e) {
             throw new RepositoryException("Unable to make local copy", e);
         } finally {
             releaseReadLock();
         }
-        NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
-        return new InternalVersionHistoryImpl(this, stateEx);
     }
 
     /**



Mime
View raw message