GERONIMO-5152 restore logic about results of a heuristic rollback. Clean up pom
git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@939929 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java
index af95279..ea8dda6 100644
--- a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java
+++ b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java
@@ -48,6 +48,7 @@
private int count = 0;
private int status;
private XAException cause;
+ private boolean evercommit;
public CommitTask(Xid xid, List<TransactionBranch> rms, Object logMark, RetryScheduler retryScheduler, TransactionLog txLog) {
this.xid = xid;
@@ -80,11 +81,13 @@
i.remove();
log.info("Transaction has been heuristically committed and rolled back");
cause = e;
+ evercommit = true;
manager.getCommitter().forget(manager.getBranchId());
} else if (e.errorCode == XAException.XA_HEURCOM) {
i.remove();
// let's not throw an exception as the transaction has been committed
log.info("Transaction has been heuristically committed");
+ evercommit = true;
manager.getCommitter().forget(manager.getBranchId());
} else if (e.errorCode == XAException.XA_RETRY) {
// do nothing, retry later
@@ -117,23 +120,16 @@
} else {
retryScheduler.retry(this, count++);
}
-// if (cause != null) {
-// if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
-// throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
-// } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
-// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
-// } else if (cause.errorCode == XAException.XA_HEURMIX) {
-// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
-// } else {
-// throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
-// }
-// }
}
public XAException getCause() {
return cause;
}
+ public boolean isEvercommit() {
+ return evercommit;
+ }
+
public int getStatus() {
return status;
}
diff --git a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
index 1612e15..ee49d74 100644
--- a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
+++ b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
@@ -746,7 +746,6 @@
}
private void commitResources(List<TransactionBranch> rms) throws HeuristicRollbackException, HeuristicMixedException, SystemException {
- //TODO there's some logic removed about dealing with a heuristic rollback on the first resource.
CommitTask commitTask = new CommitTask(xid, rms, logMark, retryScheduler, txnLog);
synchronized (this) {
status = Status.STATUS_COMMITTING;
@@ -756,10 +755,11 @@
status = commitTask.getStatus();
}
XAException cause = commitTask.getCause();
+ boolean evercommit = commitTask.isEvercommit();
if (cause != null) {
- if (cause.errorCode == XAException.XA_HEURRB) {
+ if (cause.errorCode == XAException.XA_HEURRB&& !evercommit) {
throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
- } else if (cause.errorCode == XAException.XA_HEURRB) {
+ } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
} else if (cause.errorCode == XAException.XA_HEURMIX) {
throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
@@ -769,67 +769,6 @@
}
-// XAException cause = null;
-// boolean evercommit = false;
-// try {
-// for (Iterator i = rms.iterator(); i.hasNext();) {
-// TransactionBranch manager = (TransactionBranch) i.next();
-// try {
-// manager.getCommitter().commit(manager.getBranchId(), false);
-// evercommit = true;
-// } catch (XAException e) {
-// log.error("Unexpected exception committing " + manager.getCommitter() + "; continuing to commit other RMs", e);
-//
-// if (e.errorCode == XAException.XA_HEURRB) {
-// log.info("Transaction has been heuristically rolled back");
-// cause = e;
-// manager.getCommitter().forget(manager.getBranchId());
-// } else if (e.errorCode == XAException.XA_HEURMIX) {
-// log.info("Transaction has been heuristically committed and rolled back");
-// cause = e;
-// evercommit = true;
-// manager.getCommitter().forget(manager.getBranchId());
-// } else if (e.errorCode == XAException.XA_HEURCOM) {
-// // let's not throw an exception as the transaction has been committed
-// log.info("Transaction has been heuristically committed");
-// evercommit = true;
-// manager.getCommitter().forget(manager.getBranchId());
-// } else {
-// cause = e;
-// }
-// }
-// }
-// } catch (XAException e) {
-// if (e.errorCode == XAException.XAER_NOTA) {
-// // NOTA in response to forget, means the resource already forgot the transaction
-// // ignore
-// } else {
-// throw (SystemException) new SystemException("Error during two phase commit").initCause(e);
-// }
-// }
-// //if all resources were read only, we didn't write a prepare record.
-// if (!rms.isEmpty()) {
-// try {
-// txnLog.commit(xid, logMark);
-// } catch (LogException e) {
-// log.error("Unexpected exception logging commit completion for xid " + xid, e);
-// throw (SystemException) new SystemException("Unexpected error logging commit completion for xid " + xid).initCause(e);
-// }
-// }
-// synchronized (this) {
-// status = Status.STATUS_COMMITTED;
-// }
-// if (cause != null) {
-// if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
-// throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
-// } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
-// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
-// } else if (cause.errorCode == XAException.XA_HEURMIX) {
-// throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
-// } else {
-// throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
-// }
-// }
}
private static String getStateString(int status) {
diff --git a/pom.xml b/pom.xml
index 725e0b8..74e7151 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,19 @@
<dependencyManagement>
<dependencies>
+ <!-- INTERNAL -->
+
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <!-- external -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -71,7 +84,7 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
- <version>1.0-EA-SNAPSHOT</version>
+ <version>1.0</version>
</dependency>
<dependency>
@@ -87,13 +100,6 @@
<scope>test</scope>
</dependency>
- <!-- INTERNAL -->
-
- <dependency>
- <groupId>org.apache.geronimo.components</groupId>
- <artifactId>geronimo-transaction</artifactId>
- <version>${version}</version>
- </dependency>
</dependencies>
</dependencyManagement>