jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r743343 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Date Wed, 11 Feb 2009 14:19:25 GMT
Author: jukka
Date: Wed Feb 11 14:19:24 2009
New Revision: 743343

URL: http://svn.apache.org/viewvc?rev=743343&view=rev
Log:
1.5: Merged revision 741652 (JCR-1554). Ignored other revisions.

Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 11 14:19:24 2009
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397,727402,727492,727701,728022,731896,731934,731941,73234
 7,732678,732686,732689,732693,732703,732715-732716,732719,732728,732730,732734-732738,732740,732742-732743,732745,732867,732883,733057-733059,733061,733080,734092,734366,734375,734400,734709,735401,736021,736030,736274,736276,736650-736651,736653-736656,736658,736680,737695,738087,740262,740736-740738,740747,740749-740750,741052,741100,741121,741206,741208-741210,741213,741509,741524
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964,713971,713975,714034,718218,718249-718250,718371,718376,718566,718632,718981,719225,719282,719575-719577,719579,719585-719586,719588,719592,720455,720484,720492,720524,720533,720540,720673,720679,720687,720784,720940,720969,721186,721191,721194,721235,721387-721389,721470,721495,722068-722069,722463,722465,722467,722470,722825,723281,723346,723728,723784,724300,724387,725292,727376,727388,727390,727395,727397,727402,727492,727701,728022,731896,731934,731941,73234
 7,732678,732686,732689,732693,732703,732715-732716,732719,732728,732730,732734-732738,732740,732742-732743,732745,732867,732883,733057-733059,733061,733080,734092,734366,734375,734400,734709,735401,736021,736030,736274,736276,736650-736651,736653-736656,736658,736680,737695,738087,738119,738121,738419,738422,738474,738512,739210,739212,739226,740262,740734,740736-740738,740747,740749-740750,741052,741100,741121,741206,741208-741210,741213,741509,741524,741652

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?rev=743343&r1=743342&r2=743343&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Wed Feb 11 14:19:24 2009
@@ -27,6 +27,8 @@
 import org.apache.jackrabbit.uuid.UUID;
 import org.apache.commons.collections.iterators.FilterIterator;
 import org.apache.commons.collections.Predicate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.PropertyType;
@@ -46,6 +48,11 @@
 public class XAItemStateManager extends LocalItemStateManager implements InternalXAResource
{
 
     /**
+     * The logger instance.
+     */
+    private static Logger log = LoggerFactory.getLogger(XAItemStateManager.class);
+
+    /**
      * Default change log attribute name.
      */
     private static final String DEFAULT_ATTRIBUTE_NAME = "ChangeLog";
@@ -561,4 +568,30 @@
             references.modified(refs);
         }
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * Check whether the shared state modified is contained in our transactional
+     * log: in that case, update its state as well, as it might get reused
+     * in a subsequent transaction (see JCR-1554).
+     */
+    public void stateModified(ItemState modified) {
+        ChangeLog changeLog = (ChangeLog) commitLogs.get(Thread.currentThread());
+        if (changeLog != null) {
+            ItemState local;
+            if (modified.getContainer() != this) {
+                // shared state was modified
+                try {
+                    local = changeLog.get(modified.getId());
+                    if (local != null && local.isConnected()) {
+                        local.pull();
+                    }
+                } catch (NoSuchItemStateException e) {
+                    log.warn("Modified state marked for deletion: " + modified.getId());
+                }
+            }
+        }
+        super.stateModified(modified);
+    }
 }

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=743343&r1=743342&r2=743343&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Wed Feb 11 14:19:24 2009
@@ -1332,7 +1332,7 @@
         // assert: version label known in other session
         nOther.getVersionHistory().getVersionByLabel(versionLabel);
     }
-    
+
     /**
      * Tests two different Threads for prepare and commit in a Transaction
      */
@@ -1365,4 +1365,104 @@
             fail("Committed node not visible in this session");
         }
     }
+
+    /**
+     * Test setting the same property multiple times. Exposes an issue where
+     * the same property instance got reused in subsequent transactions
+     * (see JCR-1554).
+     *
+     * @throws Exception if an error occurs
+     */
+    public void testSetProperty() throws Exception {
+        final String testNodePath = testPath + "/" + Math.random();
+
+        Session session = helper.getSuperuserSession();
+
+        // Add node
+        doTransactional(new Operation() {
+            public void invoke(Session session) throws Exception {
+                session.getRootNode().addNode(testNodePath);
+                session.save();
+            }
+        }, session);
+
+        for (int i = 1; i <= 3; i++) {
+            // Set property "name" to value "value"
+            doTransactional(new Operation() {
+                public void invoke(Session session) throws Exception {
+                    Node n = (Node) session.getItem("/" + testNodePath);
+                    n.setProperty("name", "value");
+                    session.save();
+                }
+            }, session);
+        }
+    }
+
+    /**
+     * Test deleting a subnode after creation. Exposes an issue where
+     * the same node instance got reused in subsequent transactions
+     * (see JCR-1554).
+     *
+     * @throws Exception if an error occurs
+     */
+    public void testDeleteNode() throws Exception {
+        final String testNodePath = testPath + "/" + Math.random();
+
+        Session session = helper.getSuperuserSession();
+
+        for (int i = 1; i <= 3; i++) {
+            // Add parent node
+            doTransactional(new Operation() {
+                public void invoke(Session session) throws Exception {
+                    session.getRootNode().addNode(testNodePath);
+                    session.save();
+                }
+            }, session);
+
+            // Add child node
+            doTransactional(new Operation() {
+                public void invoke(Session session) throws Exception {
+                    session.getRootNode().addNode(testNodePath + "/subnode");
+                    session.save();
+                }
+            }, session);
+
+            // Remove parent node
+            doTransactional(new Operation() {
+                public void invoke(Session session) throws Exception {
+                    session.getRootNode().getNode(testNodePath).remove();
+                    session.save();
+                }
+            }, session);
+        }
+    }
+
+    /**
+     * Operation to invoke on a session scope.
+     */
+    interface Operation {
+
+        /**
+         * Invoke the operation.
+         * @param session session to use inside operation
+         * @throws Exception if an error occurs
+         */
+        void invoke(Session session) throws Exception;
+    }
+
+    /**
+     * Wrap a session-scoped operation with a transaction.
+     *
+     * @param op operation to invoke
+     * @param session session to use for the transaction
+     * @throws Exception if an error occurs
+     */
+    private void doTransactional(Operation op, Session session) throws Exception {
+        UserTransaction utx = new UserTransactionImpl(session);
+        utx.begin();
+
+        op.invoke(session);
+
+        utx.commit();
+    }
 }



Mime
View raw message