jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948495 - in /jackrabbit/branches/1.4/jackrabbit-core: ./ src/main/java/org/apache/jackrabbit/core/ src/main/java/org/apache/jackrabbit/core/observation/ src/main/java/org/apache/jackrabbit/core/state/
Date Wed, 26 May 2010 16:37:08 GMT
Author: jukka
Date: Wed May 26 16:37:07 2010
New Revision: 948495

URL: http://svn.apache.org/viewvc?rev=948495&view=rev
Log:
1.4: Merged revision 948488 from the 1.6 branch (JCR-2456)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/   (props changed)
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/   (props
changed)
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Propchange: jackrabbit/branches/1.4/jackrabbit-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 26 16:37:07 2010
@@ -1,2 +1,3 @@
 /jackrabbit/branches/1.5/jackrabbit-core:794292
+/jackrabbit/branches/1.6/jackrabbit-core:948488
 /jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,683268,686688,691181,691550,694164,698200,698209,709142,718981,727402,733080,734366,746932

Propchange: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 26 16:37:07 2010
@@ -1,3 +1,4 @@
 /jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core:794292
+/jackrabbit/branches/1.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core:948488
 /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,683268,686688,691181,691550,694164,698200,698209,709142,718981,727402,733080,734366,746932
 /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons:760876

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=948495&r1=948494&r2=948495&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Wed May 26 16:37:07 2010
@@ -64,6 +64,7 @@ import javax.jcr.version.VersionExceptio
 import javax.jcr.version.VersionHistory;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.ConcurrentModificationException;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -1077,12 +1078,21 @@ public abstract class ItemImpl implement
              * build list of transient (i.e. new & modified) states that
              * should be persisted
              */
-            Collection dirty = getTransientStates();
+            
+            Collection dirty;
+            try {
+                dirty = getTransientStates();
+            } catch (ConcurrentModificationException e) {
+                String msg = "Concurrent modification; session is closed";
+                log.error(msg, e);
+                session.logout();
+                throw e;
+            }
+            
             if (dirty.size() == 0) {
                 // no transient items, nothing to do here
                 return;
             }
-
             /**
              * build list of transient descendants in the attic
              * (i.e. those marked as 'removed')

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=948495&r1=948494&r2=948495&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Wed May 26 16:37:07 2010
@@ -363,6 +363,11 @@ public final class EventStateCollection 
                 NodeId parentId = n.getParentId();
                 // the parent of an added item is always modified or new
                 NodeState parent = (NodeState) changes.get(parentId);
+                if (parent == null) {
+                    String msg = "Parent " + parentId + " must be changed as well.";
+                    log.error(msg);
+                    throw new ItemStateException(msg);
+                }
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set mixins = parent.getMixinTypeNames();
                 Path path = getPath(n.getNodeId(), hmgr);
@@ -376,6 +381,11 @@ public final class EventStateCollection 
             } else {
                 // property created / set
                 NodeState n = (NodeState) changes.get(state.getParentId());
+                if (n == null) {
+                    String msg = "Node " + state.getParentId() + " must be changed as well.";
+                    log.error(msg);
+                    throw new ItemStateException(msg);
+                }
                 NodeTypeImpl nodeType = getNodeType(n, session);
                 Set mixins = n.getMixinTypeNames();
                 Path path = getPath(state.getId(), hmgr);
@@ -473,7 +483,12 @@ public final class EventStateCollection 
         } catch (Exception e) {
             // also catch eventual runtime exceptions here
             // should never happen actually
-            String msg = "Item " + node.getNodeId() + " has unknown node type: " + node.getNodeTypeName();
+            String msg;
+            if (node == null) {
+                msg = "Node state is null";
+            } else {
+                msg = "Item " + node.getNodeId() + " has unknown node type: " + node.getNodeTypeName();
+            }
             log.error(msg);
             throw new ItemStateException(msg, e);
         }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=948495&r1=948494&r2=948495&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed May 26 16:37:07 2010
@@ -556,6 +556,8 @@ public class SharedItemStateManager
                  */
                 checkReferentialIntegrity(local);
 
+                checkAddedChildNodes();
+
                 /**
                  * prepare the events. this needs to be after the referential
                  * integrity check, since another transaction could have modified
@@ -693,6 +695,40 @@ public class SharedItemStateManager
         }
 
         /**
+         * Verify the added child nodes of the added or modified states exist.
+         * If they don't exist, most likely the problem is that the same session
+         * is used concurrently.
+         */
+        private void checkAddedChildNodes() throws ItemStateException {
+            for (Iterator iter = local.addedStates(); iter.hasNext();) {
+                ItemState state = (ItemState) iter.next();
+                checkAddedChildNode(state);
+            }
+            for (Iterator iter = local.modifiedStates(); iter.hasNext();) {
+                ItemState state = (ItemState) iter.next();
+                checkAddedChildNode(state);
+            }
+        }
+
+        private void checkAddedChildNode(ItemState state) throws ItemStateException {
+            if (state.isNode()) {
+                NodeState nodeState = (NodeState) state;
+                for (Iterator cneIt = nodeState.getAddedChildNodeEntries().iterator(); cneIt.hasNext();)
{
+                    NodeState.ChildNodeEntry cne = (NodeState.ChildNodeEntry) cneIt.next();
+                    NodeId id = cne.getId();
+                    if (local.get(id) == null && !id.equals(RepositoryImpl.VERSION_STORAGE_NODE_ID)
+                            && !id.equals(RepositoryImpl.NODETYPES_NODE_ID) &&
!cache.isCached(id)
+                            && !persistMgr.exists(id)) {
+                        String msg = "Trying to add a non-existing child node: " + id;
+                        log.debug(msg);
+                        throw new ItemStateException(msg);
+                    }
+                }
+            }
+        }
+
+
+        /**
          * End update operation. This will store the changes to the associated
          * <code>PersistenceManager</code>. At the end of this operation, an
          * eventual read or write lock on the item state manager will have



Mime
View raw message