JtaTransactionManager explicitly resets transaction timeout after completion
Issue: SPR-14239
This commit is contained in:
parent
5ac31fb39d
commit
1be544f8fa
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -748,8 +748,7 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
}
|
}
|
||||||
catch (NamingException ex) {
|
catch (NamingException ex) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(
|
logger.debug("No JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]", ex);
|
||||||
"No JTA TransactionSynchronizationRegistry found at default JNDI location [" + jndiName + "]", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -834,12 +833,12 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
catch (NotSupportedException ex) {
|
catch (NotSupportedException ex) {
|
||||||
// assume nested transaction not supported
|
// assume nested transaction not supported
|
||||||
throw new NestedTransactionNotSupportedException(
|
throw new NestedTransactionNotSupportedException(
|
||||||
"JTA implementation does not support nested transactions", ex);
|
"JTA implementation does not support nested transactions", ex);
|
||||||
}
|
}
|
||||||
catch (UnsupportedOperationException ex) {
|
catch (UnsupportedOperationException ex) {
|
||||||
// assume nested transaction not supported
|
// assume nested transaction not supported
|
||||||
throw new NestedTransactionNotSupportedException(
|
throw new NestedTransactionNotSupportedException(
|
||||||
"JTA implementation does not support nested transactions", ex);
|
"JTA implementation does not support nested transactions", ex);
|
||||||
}
|
}
|
||||||
catch (SystemException ex) {
|
catch (SystemException ex) {
|
||||||
throw new CannotCreateTransactionException("JTA failure on begin", ex);
|
throw new CannotCreateTransactionException("JTA failure on begin", ex);
|
||||||
|
|
@ -894,8 +893,8 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
|
|
||||||
if (!this.allowCustomIsolationLevels && isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) {
|
if (!this.allowCustomIsolationLevels && isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) {
|
||||||
throw new InvalidIsolationLevelException(
|
throw new InvalidIsolationLevelException(
|
||||||
"JtaTransactionManager does not support custom isolation levels by default - " +
|
"JtaTransactionManager does not support custom isolation levels by default - " +
|
||||||
"switch 'allowCustomIsolationLevels' to 'true'");
|
"switch 'allowCustomIsolationLevels' to 'true'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -912,6 +911,9 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
protected void applyTimeout(JtaTransactionObject txObject, int timeout) throws SystemException {
|
protected void applyTimeout(JtaTransactionObject txObject, int timeout) throws SystemException {
|
||||||
if (timeout > TransactionDefinition.TIMEOUT_DEFAULT) {
|
if (timeout > TransactionDefinition.TIMEOUT_DEFAULT) {
|
||||||
txObject.getUserTransaction().setTransactionTimeout(timeout);
|
txObject.getUserTransaction().setTransactionTimeout(timeout);
|
||||||
|
if (timeout > 0) {
|
||||||
|
txObject.resetTransactionTimeout = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1169,6 +1171,19 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doCleanupAfterCompletion(Object transaction) {
|
||||||
|
JtaTransactionObject txObject = (JtaTransactionObject) transaction;
|
||||||
|
if (txObject.resetTransactionTimeout) {
|
||||||
|
try {
|
||||||
|
txObject.getUserTransaction().setTransactionTimeout(0);
|
||||||
|
}
|
||||||
|
catch (SystemException ex) {
|
||||||
|
logger.debug("Failed to reset transaction timeout after JTA completion", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Implementation of TransactionFactory interface
|
// Implementation of TransactionFactory interface
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -39,6 +39,8 @@ public class JtaTransactionObject implements SmartTransactionObject {
|
||||||
|
|
||||||
private final UserTransaction userTransaction;
|
private final UserTransaction userTransaction;
|
||||||
|
|
||||||
|
boolean resetTransactionTimeout = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new JtaTransactionObject for the given JTA UserTransaction.
|
* Create a new JtaTransactionObject for the given JTA UserTransaction.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue