jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r900788 - in /jackrabbit/branches/2.0: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/
Date Tue, 19 Jan 2010 14:13:15 GMT
Author: jukka
Date: Tue Jan 19 14:13:14 2010
New Revision: 900788

URL: http://svn.apache.org/viewvc?rev=900788&view=rev
Log:
2.0: Merged revision 900453 (JCR-2456)

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

Propchange: jackrabbit/branches/2.0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 19 14:13:14 2010
@@ -2,4 +2,4 @@
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:891595,891629,892253,892263,894150-894151,896408,896513,896532,896857,896870,896876,896908,896940,896942-896943,896969,896977,897071,897836,897842,897858,897935,897983,897992-897993,897996,898002,898042,898267,898325,898540,898677,898699,898701,898715,898872,899102,899181,899391,899393-899394,900305,900310,900314,900702
+/jackrabbit/trunk:891595,891629,892253,892263,894150-894151,896408,896513,896532,896857,896870,896876,896908,896940,896942-896943,896969,896977,897071,897836,897842,897858,897935,897983,897992-897993,897996,898002,898042,898267,898325,898540,898677,898699,898701,898715,898872,899102,899181,899391,899393-899394,899583,899594,900305,900310,900314,900453,900702,900736

Modified: jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=900788&r1=900787&r2=900788&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Tue Jan 19 14:13:14 2010
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.ConcurrentModificationException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -481,7 +482,7 @@
                     String msg = itemMgr.safeGetJCRPath(id)
                                 + ": mandatory child node " + cnd.getName()
                                 + " does not exist";
-                    if (!nodeState.hasChildNodeEntry(cnd.getName())) {                  
   
+                    if (!nodeState.hasChildNodeEntry(cnd.getName())) {
                         log.debug(msg);
                         throw new ConstraintViolationException(msg);
                     } else {
@@ -975,7 +976,15 @@
              * build list of transient (i.e. new & modified) states that
              * should be persisted
              */
-            Collection<ItemState> dirty = getTransientStates();
+            Collection<ItemState> 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;

Modified: jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=900788&r1=900787&r2=900788&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Tue Jan 19 14:13:14 2010
@@ -404,6 +404,11 @@
                 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<Name> mixins = parent.getMixinTypeNames();
                 Path path = getPath(n.getNodeId(), hmgr);
@@ -420,6 +425,11 @@
             } 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<Name> mixins = n.getMixinTypeNames();
                 Path path = getPath(state.getId(), hmgr);
@@ -625,7 +635,12 @@
         } 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/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=900788&r1=900787&r2=900788&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Tue Jan 19 14:13:14 2010
@@ -574,6 +574,8 @@
                     checkReferentialIntegrity();
                 }
 
+                checkAddedChildNodes();
+
                 /**
                  * prepare the events. this needs to be after the referential
                  * integrity check, since another transaction could have modified
@@ -731,8 +733,8 @@
                 long t0 = System.currentTimeMillis();
                 persistMgr.store(shared);
                 succeeded = true;
-                long t1 = System.currentTimeMillis();
                 if (log.isDebugEnabled()) {
+                    long t1 = System.currentTimeMillis();
                     log.debug("persisting change log " + shared + " took " + (t1 - t0) +
"ms");
                 }
             } finally {
@@ -968,6 +970,39 @@
         }
 
         /**
+         * 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 (ItemState state : local.addedStates()) {
+                checkAddedChildNode(state);
+            }
+            for (ItemState state : local.modifiedStates()) {
+                checkAddedChildNode(state);
+            }
+        }
+
+        private void checkAddedChildNode(ItemState state) throws ItemStateException {
+            if (state.isNode()) {
+                NodeState node = (NodeState) state;
+                for (ChildNodeEntry child : node.getAddedChildNodeEntries()) {
+                    NodeId id = child.getId();
+                    if (local.get(id) == null &&
+                            !id.equals(RepositoryImpl.VERSION_STORAGE_NODE_ID) &&
+                            !id.equals(RepositoryImpl.ACTIVITIES_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);
+                    }
+                }
+            }
+        }
+
+        /**
          * Verifies that
          * <ul>
          * <li>no referenceable nodes are deleted if they are still being referenced</li>



Mime
View raw message