Skip to content

Commit a0ae849

Browse files
committed
Polishing
1 parent ef07179 commit a0ae849

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,32 @@ void notTransactional() {
107107
void defaultCommitOnAnnotatedClass() {
108108
Exception ex = new Exception();
109109
assertThatException()
110-
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
111-
.isSameAs(ex);
110+
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
111+
.isSameAs(ex);
112112
}
113113

114114
@Test
115115
void defaultRollbackOnAnnotatedClass() {
116116
RuntimeException ex = new RuntimeException();
117117
assertThatRuntimeException()
118-
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
119-
.isSameAs(ex);
118+
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
119+
.isSameAs(ex);
120120
}
121121

122122
@Test
123123
void defaultCommitOnSubclassOfAnnotatedClass() {
124124
Exception ex = new Exception();
125125
assertThatException()
126-
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
127-
.isSameAs(ex);
126+
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
127+
.isSameAs(ex);
128128
}
129129

130130
@Test
131131
void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() {
132132
Exception ex = new Exception();
133133
assertThatException()
134-
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
135-
.isSameAs(ex);
134+
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
135+
.isSameAs(ex);
136136
}
137137

138138
@Test
@@ -168,8 +168,8 @@ protected void testNotTransactional(TransactionOperationCallback toc, Throwable
168168
txManager.clear();
169169
assertThat(txManager.begun).isEqualTo(0);
170170
assertThatExceptionOfType(Throwable.class)
171-
.isThrownBy(toc::performTransactionalOperation)
172-
.isSameAs(expected);
171+
.isThrownBy(toc::performTransactionalOperation)
172+
.isSameAs(expected);
173173
assertThat(txManager.begun).isEqualTo(0);
174174
}
175175

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ protected void doSetNestedPath(@Nullable String nestedPath) {
8282
nestedPath = "";
8383
}
8484
nestedPath = canonicalFieldName(nestedPath);
85-
if (nestedPath.length() > 0 && !nestedPath.endsWith(NESTED_PATH_SEPARATOR)) {
85+
if (!nestedPath.isEmpty() && !nestedPath.endsWith(NESTED_PATH_SEPARATOR)) {
8686
nestedPath += NESTED_PATH_SEPARATOR;
8787
}
8888
this.nestedPath = nestedPath;

spring-core/src/main/java/org/springframework/util/StringUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -791,6 +791,7 @@ public static boolean pathEquals(String path1, String path2) {
791791
* and {@code "0"} through {@code "9"} stay the same.</li>
792792
* <li>Special characters {@code "-"}, {@code "_"}, {@code "."}, and {@code "*"} stay the same.</li>
793793
* <li>A sequence "{@code %<i>xy</i>}" is interpreted as a hexadecimal representation of the character.</li>
794+
* <li>For all other characters (including those already decoded), the output is undefined.</li>
794795
* </ul>
795796
* @param source the encoded String
796797
* @param charset the character set
@@ -876,7 +877,7 @@ public static Locale parseLocale(String localeValue) {
876877
@SuppressWarnings("deprecation") // for Locale constructors on JDK 19
877878
@Nullable
878879
public static Locale parseLocaleString(String localeString) {
879-
if (localeString.equals("")) {
880+
if (localeString.isEmpty()) {
880881
return null;
881882
}
882883

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,11 +28,12 @@
2828
import org.springframework.transaction.interceptor.TransactionAttribute;
2929

3030
/**
31-
* Strategy implementation for parsing EJB3's {@link jakarta.ejb.TransactionAttribute}
32-
* annotation.
31+
* Strategy implementation for parsing EJB3's {@link jakarta.ejb.TransactionAttribute} annotation.
3332
*
3433
* @author Juergen Hoeller
3534
* @since 2.5
35+
* @see SpringTransactionAnnotationParser
36+
* @see JtaTransactionAnnotationParser
3637
*/
3738
@SuppressWarnings("serial")
3839
public class Ejb3TransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -163,10 +163,10 @@
163163
public @interface EnableTransactionManagement {
164164

165165
/**
166-
* Indicate whether subclass-based (CGLIB) proxies are to be created ({@code true}) as
167-
* opposed to standard Java interface-based proxies ({@code false}). The default is
168-
* {@code false}. <strong>Applicable only if {@link #mode()} is set to
169-
* {@link AdviceMode#PROXY}</strong>.
166+
* Indicate whether subclass-based (CGLIB) proxies are to be created ({@code true})
167+
* as opposed to standard Java interface-based proxies ({@code false}).
168+
* The default is {@code false}. <strong>Applicable only if {@link #mode()}
169+
* is set to {@link AdviceMode#PROXY}</strong>.
170170
* <p>Note that setting this attribute to {@code true} will affect <em>all</em>
171171
* Spring-managed beans requiring proxying, not just those marked with
172172
* {@code @Transactional}. For example, other beans marked with Spring's

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,8 @@
3535
*
3636
* @author Juergen Hoeller
3737
* @since 4.0
38+
* @see SpringTransactionAnnotationParser
39+
* @see Ejb3TransactionAnnotationParser
3840
*/
3941
@SuppressWarnings("serial")
4042
public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
@@ -65,7 +67,7 @@ protected TransactionAttribute parseTransactionAnnotation(AnnotationAttributes a
6567
RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute();
6668

6769
rbta.setPropagationBehaviorName(
68-
RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value").toString());
70+
RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value"));
6971

7072
List<RollbackRuleAttribute> rollbackRules = new ArrayList<>();
7173
for (Class<?> rbRule : attributes.getClassArray("rollbackOn")) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@
3939
* @author Juergen Hoeller
4040
* @author Mark Paluch
4141
* @since 2.5
42+
* @see JtaTransactionAnnotationParser
43+
* @see Ejb3TransactionAnnotationParser
4244
*/
4345
@SuppressWarnings("serial")
4446
public class SpringTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ public List<RollbackRuleAttribute> getRollbackRules() {
118118
/**
119119
* Winning rule is the shallowest rule (that is, the closest in the
120120
* inheritance hierarchy to the exception). If no rule applies (-1),
121-
* return false.
121+
* return {@code false}.
122122
* @see TransactionAttribute#rollbackOn(java.lang.Throwable)
123123
*/
124124
@Override

spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ void spr14322FindsOnInterfaceWithCglibProxy() {
288288
}
289289

290290
@Test
291-
void gh24502AppliesTransactionOnlyOnAnnotatedInterface() {
292-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Gh24502ConfigA.class);
291+
void gh24502AppliesTransactionFromAnnotatedInterface() {
292+
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Gh24502Config.class);
293293
Object bean = ctx.getBean("testBean");
294294
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
295295

@@ -590,7 +590,7 @@ public void methodTwo() {
590590

591591
@Configuration
592592
@EnableTransactionManagement
593-
static class Gh24502ConfigA {
593+
static class Gh24502Config {
594594

595595
@Bean
596596
public MixedTransactionalTestService testBean() {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,34 @@ public class TestTransactionExecutionListener implements TransactionExecutionLis
4949

5050

5151
@Override
52-
public void beforeBegin(TransactionExecution transactionState) {
52+
public void beforeBegin(TransactionExecution transaction) {
5353
this.beforeBeginCalled = true;
5454
}
5555

5656
@Override
57-
public void afterBegin(TransactionExecution transactionState, @Nullable Throwable beginFailure) {
57+
public void afterBegin(TransactionExecution transaction, @Nullable Throwable beginFailure) {
5858
this.afterBeginCalled = true;
5959
this.beginFailure = beginFailure;
6060
}
6161

6262
@Override
63-
public void beforeCommit(TransactionExecution transactionState) {
63+
public void beforeCommit(TransactionExecution transaction) {
6464
this.beforeCommitCalled = true;
6565
}
6666

6767
@Override
68-
public void afterCommit(TransactionExecution transactionState, @Nullable Throwable commitFailure) {
68+
public void afterCommit(TransactionExecution transaction, @Nullable Throwable commitFailure) {
6969
this.afterCommitCalled = true;
7070
this.commitFailure = commitFailure;
7171
}
7272

7373
@Override
74-
public void beforeRollback(TransactionExecution transactionState) {
74+
public void beforeRollback(TransactionExecution transaction) {
7575
this.beforeRollbackCalled = true;
7676
}
7777

7878
@Override
79-
public void afterRollback(TransactionExecution transactionState, @Nullable Throwable rollbackFailure) {
79+
public void afterRollback(TransactionExecution transaction, @Nullable Throwable rollbackFailure) {
8080
this.afterRollbackCalled = true;
8181
this.rollbackFailure = rollbackFailure;
8282
}

0 commit comments

Comments
 (0)