Skip to content

Commit

Permalink
[JBEAP-16107] [WFTC-54] forbid to enlist XAResource to a timeouted tr…
Browse files Browse the repository at this point in the history
…ansaction
  • Loading branch information
ochaloup authored and bmaxwell committed Jan 14, 2019
1 parent 2a54de4 commit 3e5d75c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -18,8 +18,6 @@

package org.wildfly.transaction.client;

import static java.lang.Math.max;

import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
Expand Down Expand Up @@ -148,7 +146,8 @@ public int getTransactionTimeout() {

public boolean enlistResource(final XAResource xaRes) throws RollbackException, IllegalStateException, SystemException {
Assert.checkNotNullParam("xaRes", xaRes);
final int estimatedRemainingTime = max(1, getEstimatedRemainingTime());
final int estimatedRemainingTime = getEstimatedRemainingTime();
if(estimatedRemainingTime == 0) throw Log.log.cannotEnlistToTimeOutTransaction(xaRes, this);
try {
xaRes.setTransactionTimeout(estimatedRemainingTime);
} catch (XAException e) {
Expand Down
Expand Up @@ -362,6 +362,9 @@ public interface Log extends BasicLogger {
@Message(id = 90, value = "Cannot assign location \"%s\" to transaction because it is already located at \"%s\"")
IllegalStateException locationAlreadyInitialized(URI newLocation, URI oldLocation);

@Message(id = 97, value = "Cannot enlist XA resource '%s' to transaction '%s' as timeout already elapsed")
SystemException cannotEnlistToTimeOutTransaction(XAResource xaRes, Transaction transaction);

@LogMessage(level = Logger.Level.WARN)
@Message(id = 99, value = "Error while removing imported transaction of xid %s from the underlying transaction manager")
void cannotRemoveImportedTransaction(Xid xid, @Cause XAException e);
Expand Down

0 comments on commit 3e5d75c

Please sign in to comment.