Author: manik.surtani(a)jboss.com
Date: 2009-02-25 11:42:15 -0500 (Wed, 25 Feb 2009)
New Revision: 7787
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
Log:
Receiving a commit for which there is no prepare is allowed
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-02-25
16:30:09 UTC (rev 7786)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-02-25
16:42:15 UTC (rev 7787)
@@ -21,6 +21,12 @@
*/
package org.jboss.cache.transaction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.commands.WriteCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.marshall.Marshaller;
+
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -30,12 +36,6 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.marshall.Marshaller;
-
/**
* Logs transactions and writes for Non-Blocking State Transfer
*
@@ -79,13 +79,10 @@
public void logCommit(GlobalTransaction gtx)
{
PrepareCommand command = pendingPrepares.remove(gtx);
- if (command == null)
- {
- log.error("Could not find matching prepare for commit: " + gtx);
- return;
- }
-
- addEntry(new LogEntry(gtx, command.getModifications()));
+ // it is perfectly normal for a prepare not to be logged for this gtx, for example
if a transaction did not
+ // modify anything, then beforeCompletion() is not invoked and logPrepare() will
not be called to register the
+ // prepare.
+ if (command != null) addEntry(new LogEntry(gtx, command.getModifications()));
}
private void addEntry(LogEntry entry)
@@ -114,7 +111,7 @@
{
// Just in case...
if (gtx != null) pendingPrepares.remove(gtx);
- addEntry(new LogEntry(gtx, modifications));
+ if (!modifications.isEmpty()) addEntry(new LogEntry(gtx, modifications));
}
public void logNoTxWrite(WriteCommand write)
Show replies by thread