diff --git a/spring-tx/src/main/java/org/springframework/jca/support/SimpleBootstrapContext.java b/spring-tx/src/main/java/org/springframework/jca/support/SimpleBootstrapContext.java index c607a6f266..fac8e45d5a 100644 --- a/spring-tx/src/main/java/org/springframework/jca/support/SimpleBootstrapContext.java +++ b/spring-tx/src/main/java/org/springframework/jca/support/SimpleBootstrapContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import org.springframework.util.Assert; public class SimpleBootstrapContext implements BootstrapContext { @Nullable - private WorkManager workManager; + private final WorkManager workManager; @Nullable private XATerminator xaTerminator; diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java index 13f16a20e9..5d4e2e9395 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -194,10 +194,9 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa if (this == other) { return true; } - if (!(other instanceof AnnotationTransactionAttributeSource)) { + if (!(other instanceof AnnotationTransactionAttributeSource otherTas)) { return false; } - AnnotationTransactionAttributeSource otherTas = (AnnotationTransactionAttributeSource) other; return (this.annotationParsers.equals(otherTas.annotationParsers) && this.publicMethodsOnly == otherTas.publicMethodsOnly); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java index 80983806ed..e50c9b5231 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,8 +128,7 @@ public abstract class AbstractFallbackTransactionAttributeSource } else { String methodIdentification = ClassUtils.getQualifiedMethodName(method, targetClass); - if (txAttr instanceof DefaultTransactionAttribute) { - DefaultTransactionAttribute dta = (DefaultTransactionAttribute) txAttr; + if (txAttr instanceof DefaultTransactionAttribute dta) { dta.setDescriptor(methodIdentification); dta.resolveAttributeStrings(this.embeddedValueResolver); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.java index c5698a7cb1..d1f068dbf4 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MatchAlwaysTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,8 +49,8 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu * @see org.springframework.transaction.interceptor.TransactionAttributeEditor */ public void setTransactionAttribute(TransactionAttribute transactionAttribute) { - if (transactionAttribute instanceof DefaultTransactionAttribute) { - ((DefaultTransactionAttribute) transactionAttribute).resolveAttributeStrings(null); + if (transactionAttribute instanceof DefaultTransactionAttribute dta) { + dta.resolveAttributeStrings(null); } this.transactionAttribute = transactionAttribute; } @@ -68,10 +68,9 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu if (this == other) { return true; } - if (!(other instanceof MatchAlwaysTransactionAttributeSource)) { + if (!(other instanceof MatchAlwaysTransactionAttributeSource otherTas)) { return false; } - MatchAlwaysTransactionAttributeSource otherTas = (MatchAlwaysTransactionAttributeSource) other; return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java index 9407b1881a..e328a88a2e 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,8 +199,8 @@ public class MethodMapTransactionAttributeSource if (logger.isDebugEnabled()) { logger.debug("Adding transactional method [" + method + "] with attribute [" + attr + "]"); } - if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) { - ((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver); + if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) { + dta.resolveAttributeStrings(this.embeddedValueResolver); } this.transactionAttributeMap.put(method, attr); } @@ -242,10 +242,9 @@ public class MethodMapTransactionAttributeSource if (this == other) { return true; } - if (!(other instanceof MethodMapTransactionAttributeSource)) { + if (!(other instanceof MethodMapTransactionAttributeSource otherTas)) { return false; } - MethodMapTransactionAttributeSource otherTas = (MethodMapTransactionAttributeSource) other; return ObjectUtils.nullSafeEquals(this.methodMap, otherTas.methodMap); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java index b9c8996424..a0f4e15bf4 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,8 +101,8 @@ public class NameMatchTransactionAttributeSource if (logger.isDebugEnabled()) { logger.debug("Adding transactional method [" + methodName + "] with attribute [" + attr + "]"); } - if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute) { - ((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver); + if (this.embeddedValueResolver != null && attr instanceof DefaultTransactionAttribute dta) { + dta.resolveAttributeStrings(this.embeddedValueResolver); } this.nameMap.put(methodName, attr); } @@ -115,8 +115,8 @@ public class NameMatchTransactionAttributeSource @Override public void afterPropertiesSet() { for (TransactionAttribute attr : this.nameMap.values()) { - if (attr instanceof DefaultTransactionAttribute) { - ((DefaultTransactionAttribute) attr).resolveAttributeStrings(this.embeddedValueResolver); + if (attr instanceof DefaultTransactionAttribute dta) { + dta.resolveAttributeStrings(this.embeddedValueResolver); } } } @@ -167,10 +167,9 @@ public class NameMatchTransactionAttributeSource if (this == other) { return true; } - if (!(other instanceof NameMatchTransactionAttributeSource)) { + if (!(other instanceof NameMatchTransactionAttributeSource otherTas)) { return false; } - NameMatchTransactionAttributeSource otherTas = (NameMatchTransactionAttributeSource) other; return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java index e0552d41f2..f9defeecd4 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RollbackRuleAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,10 +129,9 @@ public class RollbackRuleAttribute implements Serializable{ if (this == other) { return true; } - if (!(other instanceof RollbackRuleAttribute)) { + if (!(other instanceof RollbackRuleAttribute rhs)) { return false; } - RollbackRuleAttribute rhs = (RollbackRuleAttribute) other; return this.exceptionName.equals(rhs.exceptionName); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java index ceef2bd82f..a7cdc8867d 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAttributeSourcePointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,10 +52,9 @@ abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPoi if (this == other) { return true; } - if (!(other instanceof TransactionAttributeSourcePointcut)) { + if (!(other instanceof TransactionAttributeSourcePointcut otherPc)) { return false; } - TransactionAttributeSourcePointcut otherPc = (TransactionAttributeSourcePointcut) other; return ObjectUtils.nullSafeEquals(getTransactionAttributeSource(), otherPc.getTransactionAttributeSource()); }