jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r705938 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state: ChangeLog.java XAItemStateManager.java
Date Sat, 18 Oct 2008 23:54:45 GMT
Author: jukka
Date: Sat Oct 18 16:54:45 2008
New Revision: 705938

URL: http://svn.apache.org/viewvc?rev=705938&view=rev
Log:
JCR-1813: Invalid journal records during XATransactions

Only update the repository in an XA transaction if there actually are repository changes within
that transaction.

Fix proposed by Stephane Landelle.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java?rev=705938&r1=705937&r2=705938&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ChangeLog.java
Sat Oct 18 16:54:45 2008
@@ -49,6 +49,20 @@
     private final Map modifiedRefs = new LinkedMap();
 
     /**
+     * Checks whether this change log contains any changes. This method is
+     * used to avoid extra work on updates that contain no changes.
+     *
+     * @since Apache Jackrabbit 1.5
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1813">JCR-1813</a>
+     * @return <code>true</code> if this log contains at least one change,
+     *         <code>false</code> otherwise
+     */
+    public boolean hasUpdates() { 
+        return !(addedStates.isEmpty() && modifiedStates.isEmpty()
+                && deletedStates.isEmpty() && modifiedRefs.isEmpty()); 
+    }
+
+    /**
      * A state has been added
      *
      * @param state state that has been added

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?rev=705938&r1=705937&r2=705938&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Sat Oct 18 16:54:45 2008
@@ -138,7 +138,7 @@
      */
     public void prepare(TransactionContext tx) throws TransactionException {
         ChangeLog txLog = (ChangeLog) tx.getAttribute(attributeName);
-        if (txLog != null) {
+        if (txLog != null && txLog.hasUpdates()) {
             try {
                 if (virtualProvider != null) {
                     updateVirtualReferences(txLog);
@@ -159,7 +159,7 @@
      */
     public void commit(TransactionContext tx) throws TransactionException {
         ChangeLog txLog = (ChangeLog) tx.getAttribute(attributeName);
-        if (txLog != null) {
+        if (txLog != null && txLog.hasUpdates()) {
             try {
                 update.end();
             } catch (ItemStateException ise) {
@@ -175,7 +175,7 @@
      */
     public void rollback(TransactionContext tx) {
         ChangeLog txLog = (ChangeLog) tx.getAttribute(attributeName);
-        if (txLog != null) {
+        if (txLog != null && txLog.hasUpdates()) {
             if (update != null) {
                 update.cancel();
             }



Mime
View raw message