Browse Source

Merge branch '6.1.x'

pull/32380/head
Juergen Hoeller 2 years ago
parent
commit
6f7f032ced
  1. 20
      spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java
  2. 2
      spring-context/src/main/java/org/springframework/validation/AbstractErrors.java
  3. 7
      spring-tx/src/main/java/org/springframework/transaction/annotation/Ejb3TransactionAnnotationParser.java
  4. 6
      spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java
  5. 4
      spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java
  6. 2
      spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java
  7. 12
      spring-tx/src/testFixtures/java/org/springframework/transaction/testfixture/TestTransactionExecutionListener.java

20
spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java

@ -107,32 +107,32 @@ class TransactionAspectTests {
void defaultCommitOnAnnotatedClass() { void defaultCommitOnAnnotatedClass() {
Exception ex = new Exception(); Exception ex = new Exception();
assertThatException() assertThatException()
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false)) .isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
.isSameAs(ex); .isSameAs(ex);
} }
@Test @Test
void defaultRollbackOnAnnotatedClass() { void defaultRollbackOnAnnotatedClass() {
RuntimeException ex = new RuntimeException(); RuntimeException ex = new RuntimeException();
assertThatRuntimeException() assertThatRuntimeException()
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true)) .isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
.isSameAs(ex); .isSameAs(ex);
} }
@Test @Test
void defaultCommitOnSubclassOfAnnotatedClass() { void defaultCommitOnSubclassOfAnnotatedClass() {
Exception ex = new Exception(); Exception ex = new Exception();
assertThatException() assertThatException()
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false)) .isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
.isSameAs(ex); .isSameAs(ex);
} }
@Test @Test
void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() { void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() {
Exception ex = new Exception(); Exception ex = new Exception();
assertThatException() assertThatException()
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false)) .isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
.isSameAs(ex); .isSameAs(ex);
} }
@Test @Test
@ -168,8 +168,8 @@ class TransactionAspectTests {
txManager.clear(); txManager.clear();
assertThat(txManager.begun).isEqualTo(0); assertThat(txManager.begun).isEqualTo(0);
assertThatExceptionOfType(Throwable.class) assertThatExceptionOfType(Throwable.class)
.isThrownBy(toc::performTransactionalOperation) .isThrownBy(toc::performTransactionalOperation)
.isSameAs(expected); .isSameAs(expected);
assertThat(txManager.begun).isEqualTo(0); assertThat(txManager.begun).isEqualTo(0);
} }

2
spring-context/src/main/java/org/springframework/validation/AbstractErrors.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 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.

7
spring-tx/src/main/java/org/springframework/transaction/annotation/Ejb3TransactionAnnotationParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2024 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.
@ -28,11 +28,12 @@ import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttribute;
/** /**
* Strategy implementation for parsing EJB3's {@link jakarta.ejb.TransactionAttribute} * Strategy implementation for parsing EJB3's {@link jakarta.ejb.TransactionAttribute} annotation.
* annotation.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5 * @since 2.5
* @see SpringTransactionAnnotationParser
* @see JtaTransactionAnnotationParser
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class Ejb3TransactionAnnotationParser implements TransactionAnnotationParser, Serializable { public class Ejb3TransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

6
spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2024 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.
@ -35,6 +35,8 @@ import org.springframework.transaction.interceptor.TransactionAttribute;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.0 * @since 4.0
* @see SpringTransactionAnnotationParser
* @see Ejb3TransactionAnnotationParser
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable { public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
@ -65,7 +67,7 @@ public class JtaTransactionAnnotationParser implements TransactionAnnotationPars
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute(); RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
rbta.setPropagationBehaviorName( rbta.setPropagationBehaviorName(
RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value").toString()); RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value"));
List<RollbackRuleAttribute> rollbackRules = new ArrayList<>(); List<RollbackRuleAttribute> rollbackRules = new ArrayList<>();
for (Class<?> rbRule : attributes.getClassArray("rollbackOn")) { for (Class<?> rbRule : attributes.getClassArray("rollbackOn")) {

4
spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2024 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 @@ import org.springframework.util.StringUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Mark Paluch * @author Mark Paluch
* @since 2.5 * @since 2.5
* @see JtaTransactionAnnotationParser
* @see Ejb3TransactionAnnotationParser
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class SpringTransactionAnnotationParser implements TransactionAnnotationParser, Serializable { public class SpringTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

2
spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java

@ -117,7 +117,7 @@ public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute i
/** /**
* Winning rule is the shallowest rule (that is, the closest in the * Winning rule is the shallowest rule (that is, the closest in the
* inheritance hierarchy to the exception). If no rule applies (-1), * inheritance hierarchy to the exception). If no rule applies (-1),
* return false. * return {@code false}.
* @see TransactionAttribute#rollbackOn(java.lang.Throwable) * @see TransactionAttribute#rollbackOn(java.lang.Throwable)
*/ */
@Override @Override

12
spring-tx/src/testFixtures/java/org/springframework/transaction/testfixture/TestTransactionExecutionListener.java

@ -49,34 +49,34 @@ public class TestTransactionExecutionListener implements TransactionExecutionLis
@Override @Override
public void beforeBegin(TransactionExecution transactionState) { public void beforeBegin(TransactionExecution transaction) {
this.beforeBeginCalled = true; this.beforeBeginCalled = true;
} }
@Override @Override
public void afterBegin(TransactionExecution transactionState, @Nullable Throwable beginFailure) { public void afterBegin(TransactionExecution transaction, @Nullable Throwable beginFailure) {
this.afterBeginCalled = true; this.afterBeginCalled = true;
this.beginFailure = beginFailure; this.beginFailure = beginFailure;
} }
@Override @Override
public void beforeCommit(TransactionExecution transactionState) { public void beforeCommit(TransactionExecution transaction) {
this.beforeCommitCalled = true; this.beforeCommitCalled = true;
} }
@Override @Override
public void afterCommit(TransactionExecution transactionState, @Nullable Throwable commitFailure) { public void afterCommit(TransactionExecution transaction, @Nullable Throwable commitFailure) {
this.afterCommitCalled = true; this.afterCommitCalled = true;
this.commitFailure = commitFailure; this.commitFailure = commitFailure;
} }
@Override @Override
public void beforeRollback(TransactionExecution transactionState) { public void beforeRollback(TransactionExecution transaction) {
this.beforeRollbackCalled = true; this.beforeRollbackCalled = true;
} }
@Override @Override
public void afterRollback(TransactionExecution transactionState, @Nullable Throwable rollbackFailure) { public void afterRollback(TransactionExecution transaction, @Nullable Throwable rollbackFailure) {
this.afterRollbackCalled = true; this.afterRollbackCalled = true;
this.rollbackFailure = rollbackFailure; this.rollbackFailure = rollbackFailure;
} }

Loading…
Cancel
Save