jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1176515 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemSaveOperation.java state/SessionItemStateManager.java
Date Tue, 27 Sep 2011 18:43:46 GMT
Author: jukka
Date: Tue Sep 27 18:43:46 2011
New Revision: 1176515

URL: http://svn.apache.org/viewvc?rev=1176515&view=rev
Log:
JCR-3063: NullPointerException in ItemManager

Add a few extra checks against NPEs and CMEs

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java?rev=1176515&r1=1176514&r2=1176515&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemSaveOperation.java
Tue Sep 27 18:43:46 2011
@@ -490,9 +490,18 @@ class ItemSaveOperation implements Sessi
                  * its primary type has changed, check its node type against the
                  * required node type in its definition
                  */
-                if (nodeState.getStatus() == ItemState.STATUS_NEW
-                        || !nodeState.getNodeTypeName().equals(
-                            ((NodeState) nodeState.getOverlayedState()).getNodeTypeName()))
{
+                boolean primaryTypeChanged =
+                        nodeState.getStatus() == ItemState.STATUS_NEW;
+                if (!primaryTypeChanged) {
+                    NodeState overlaid =
+                            (NodeState) nodeState.getOverlayedState();
+                    if (overlaid != null) {
+                        Name newName = nodeState.getNodeTypeName();
+                        Name oldName = overlaid.getNodeTypeName();
+                        primaryTypeChanged = !newName.equals(oldName);
+                    }
+                }
+                if (primaryTypeChanged) {
                     for (NodeType ntReq : nodeDef.getRequiredPrimaryTypes()) {
                         Name ntName = ((NodeTypeImpl) ntReq).getQName();
                         if (!(pnt.getQName().equals(ntName)

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=1176515&r1=1176514&r2=1176515&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Tue Sep 27 18:43:46 2011
@@ -470,7 +470,9 @@ public class SessionItemStateManager
         Collection<NodeId> candidateIds = new LinkedList<NodeId>();
         try {
             HierarchyManager hierMgr = getHierarchyMgr();
-            for (ItemState state : transientStore.values()) {
+            ItemState[] states =
+                    transientStore.values().toArray(new ItemState[0]);
+            for (ItemState state : states) {
                 if (state.getStatus() == ItemState.STATUS_EXISTING_MODIFIED
                         || state.getStatus() == ItemState.STATUS_STALE_DESTROYED) {
                     NodeId nodeId;
@@ -567,7 +569,6 @@ public class SessionItemStateManager
      */
     public NodeState createTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId,
int initialStatus)
             throws ItemStateException {
-
         // check map; synchronized to ensure an entry is not created twice.
         synchronized (transientStore) {
             if (transientStore.containsKey(id)) {



Mime
View raw message