jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1173558 - in /jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: NodeImpl.java PropertyImpl.java state/ItemState.java state/SessionItemStateManager.java
Date Wed, 21 Sep 2011 10:20:39 GMT
Author: jukka
Date: Wed Sep 21 10:20:38 2011
New Revision: 1173558

URL: http://svn.apache.org/viewvc?rev=1173558&view=rev
Log:
JCR-2272: Errors during concurrent session import of nodes with same UUIDs

Use ItemStateException instead of IllegalStateException to report ItemState consistency issues.
This avoids problem caused by unexpected RuntimeExceptions going up through the entire call
stack.
TODO: We should be more resilient against such issues.

Modified:
    jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
    jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=1173558&r1=1173557&r2=1173558&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Wed Sep 21 10:20:38 2011
@@ -863,7 +863,11 @@ public class NodeImpl extends ItemImpl i
         NodeState localState = (NodeState) transientState.getOverlayedState();
         if (localState == null) {
             // this node is 'new'
-            localState = stateMgr.createNew(transientState);
+            try {
+                localState = stateMgr.createNew(transientState);
+            } catch (ItemStateException e) {
+                throw new InvalidItemStateException(e);
+            }
         }
 
         synchronized (localState) {

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=1173558&r1=1173557&r2=1173558&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Wed Sep 21 10:20:38 2011
@@ -144,7 +144,11 @@ public class PropertyImpl extends ItemIm
         PropertyState persistentState = (PropertyState) transientState.getOverlayedState();
         if (persistentState == null) {
             // this property is 'new'
-            persistentState = stateMgr.createNew(transientState);
+            try {
+                persistentState = stateMgr.createNew(transientState);
+            } catch (ItemStateException e) {
+                throw new InvalidItemStateException(e);
+            }
         }
 
         synchronized (persistentState) {

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java?rev=1173558&r1=1173557&r2=1173558&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
Wed Sep 21 10:20:38 2011
@@ -132,7 +132,7 @@ public abstract class ItemState {
                 throw new IllegalArgumentException(msg);
         }
         this.isTransient = isTransient;
-        connect(overlayedState);
+        this.overlayedState = overlayedState;
     }
 
     /**
@@ -176,11 +176,13 @@ public abstract class ItemState {
     /**
      * Connect this state to some underlying overlayed state.
      */
-    protected void connect(ItemState overlayedState) {
-        if (this.overlayedState != null) {
-            if (this.overlayedState != overlayedState) {
-                throw new IllegalStateException("Item state already connected to another
underlying state: " + this);
-            }
+    protected void connect(ItemState overlayedState)
+            throws ItemStateException {
+        if (this.overlayedState != null
+                && this.overlayedState != overlayedState) {
+            throw new ItemStateException(
+                    "Item state already connected to another"
+                            + " underlying state: " + this);
         }
         this.overlayedState = overlayedState;
     }
@@ -189,9 +191,9 @@ public abstract class ItemState {
      * Reconnect this state to the overlayed state that it has been
      * disconnected from earlier.
      */
-    protected void reconnect() {
+    protected void reconnect() throws ItemStateException {
         if (this.overlayedState == null) {
-            throw new IllegalStateException(
+            throw new ItemStateException(
                     "Item state cannot be reconnected because there's no"
                     + " underlying state to reconnect to: " + this);
         }

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=1173558&r1=1173557&r2=1173558&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Wed Sep 21 10:20:38 2011
@@ -229,8 +229,7 @@ public class SessionItemStateManager
      * connects the newly created persistent state with the transient state.
      */
     public NodeState createNew(NodeState transientState)
-            throws IllegalStateException {
-
+            throws ItemStateException {
         NodeState persistentState = createNew(transientState.getNodeId(),
                 transientState.getNodeTypeName(),
                 transientState.getParentId());
@@ -251,8 +250,7 @@ public class SessionItemStateManager
      * connects the newly created persistent state with the transient state.
      */
     public PropertyState createNew(PropertyState transientState)
-            throws IllegalStateException {
-
+            throws ItemStateException {
         PropertyState persistentState = createNew(transientState.getName(),
                 transientState.getParentId());
         transientState.connect(persistentState);



Mime
View raw message