From 45080e3724e68ac0bd07aff0e8282d700f8baefa Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 28 Dec 2023 11:27:18 +0800 Subject: [PATCH] Remove unnecessary final modifier final is useless for private and static methods See gh-31916 --- .../annotation/ConfigurationClassAndBFPPTests.java | 2 +- .../core/type/AbstractMethodMetadataTests.java | 2 +- .../test/annotation/SystemProfileValueSource.java | 2 +- .../test/context/cache/ContextCacheTestUtils.java | 12 ++++++------ .../web/util/pattern/PathPatternParserTests.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java index a90213764d..0140212d89 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java @@ -88,7 +88,7 @@ class ConfigurationClassAndBFPPTests { @Autowired TestBean autowiredTestBean; @Bean - public static final BeanFactoryPostProcessor bfpp() { + public static BeanFactoryPostProcessor bfpp() { return beanFactory -> { // no-op }; diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java index dee457340c..c0bd0c2b94 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java @@ -263,7 +263,7 @@ public abstract class AbstractMethodMetadataTests { public static class WithPrivateMethod { @Tag - private final String test() { + private String test() { return ""; } diff --git a/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java b/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java index 3cc01fc664..7d1f7c11f9 100644 --- a/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java +++ b/spring-test/src/main/java/org/springframework/test/annotation/SystemProfileValueSource.java @@ -34,7 +34,7 @@ public final class SystemProfileValueSource implements ProfileValueSource { /** * Obtain the canonical instance of this ProfileValueSource. */ - public static final SystemProfileValueSource getInstance() { + public static SystemProfileValueSource getInstance() { return INSTANCE; } diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTestUtils.java b/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTestUtils.java index ef7a05d486..4148168c6f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTestUtils.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTestUtils.java @@ -32,7 +32,7 @@ public class ContextCacheTestUtils { /** * Reset the state of the static context cache in {@link DefaultCacheAwareContextLoaderDelegate}. */ - public static final void resetContextCache() { + public static void resetContextCache() { DefaultCacheAwareContextLoaderDelegate.defaultContextCache.reset(); } @@ -43,7 +43,7 @@ public class ContextCacheTestUtils { * @param expectedHitCount the expected hit count * @param expectedMissCount the expected miss count */ - public static final void assertContextCacheStatistics(int expectedSize, int expectedHitCount, int expectedMissCount) { + public static void assertContextCacheStatistics(int expectedSize, int expectedHitCount, int expectedMissCount) { assertContextCacheStatistics(null, expectedSize, expectedHitCount, expectedMissCount); } @@ -55,8 +55,8 @@ public class ContextCacheTestUtils { * @param expectedHitCount the expected hit count * @param expectedMissCount the expected miss count */ - public static final void assertContextCacheStatistics(String usageScenario, int expectedSize, int expectedHitCount, - int expectedMissCount) { + public static void assertContextCacheStatistics(String usageScenario, int expectedSize, int expectedHitCount, + int expectedMissCount) { assertContextCacheStatistics(DefaultCacheAwareContextLoaderDelegate.defaultContextCache, usageScenario, expectedSize, expectedHitCount, expectedMissCount); } @@ -70,8 +70,8 @@ public class ContextCacheTestUtils { * @param expectedHitCount the expected hit count * @param expectedMissCount the expected miss count */ - public static final void assertContextCacheStatistics(ContextCache contextCache, String usageScenario, - int expectedSize, int expectedHitCount, int expectedMissCount) { + public static void assertContextCacheStatistics(ContextCache contextCache, String usageScenario, + int expectedSize, int expectedHitCount, int expectedMissCount) { String context = (StringUtils.hasText(usageScenario) ? " (" + usageScenario + ")" : ""); diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java index b96c749d75..d15ece539c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java @@ -474,7 +474,7 @@ public class PathPatternParserTests { } @SafeVarargs - private final void assertPathElements(PathPattern p, Class... sectionClasses) { + private void assertPathElements(PathPattern p, Class... sectionClasses) { PathElement head = p.getHeadSection(); for (Class sectionClass : sectionClasses) { if (head == null) {