From df2943074aecd0acfbc08018ebfe146e4a38f1b3 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Mon, 2 Feb 2026 11:36:33 +0800 Subject: [PATCH] Members declared in final classes should not be protected Since final classes cannot be inherited, marking the method as protected may be confusing. It is better to declare such members as private or package-visible instead. Signed-off-by: Yanming Zhou --- .../java/org/springframework/boot/build/bom/BomResolver.java | 2 +- .../boot/autoconfigure/info/ProjectInfoAutoConfiguration.java | 2 +- .../org/springframework/boot/test/util/TestPropertyValues.java | 2 +- .../org/springframework/boot/logging/log4j2/ColorConverter.java | 2 +- .../boot/loader/tools/BuildPropertiesWriter.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomResolver.java index fe865002f646..f0165d562ba7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/BomResolver.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/BomResolver.java @@ -199,7 +199,7 @@ private File parentBomFile(Node bom) { private static final class Node { - protected final XPath xpath; + private final XPath xpath; private final org.w3c.dom.Node delegate; diff --git a/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java b/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java index f08b08a211c7..99fc21e9b32c 100644 --- a/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java +++ b/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java @@ -75,7 +75,7 @@ BuildProperties buildProperties() throws Exception { loadFrom(this.properties.getBuild().getLocation(), "build", this.properties.getBuild().getEncoding())); } - protected Properties loadFrom(Resource location, String prefix, Charset encoding) throws IOException { + private Properties loadFrom(Resource location, String prefix, Charset encoding) throws IOException { prefix = prefix.endsWith(".") ? prefix : prefix + "."; Properties source = loadSource(location, encoding); Properties target = new Properties(); diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 8091c9c68e63..fc9eb2d83158 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -310,7 +310,7 @@ public Class getSourceClass() { return this.sourceClass; } - protected String applySuffix(String name) { + private String applySuffix(String name) { return (this.suffix != null) ? name + "-" + this.suffix : name; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index a75deece60fd..af4a4d64921d 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -110,7 +110,7 @@ public void format(LogEvent event, StringBuilder toAppendTo) { } } - protected void appendAnsiString(StringBuilder toAppendTo, String in, AnsiElement element) { + private void appendAnsiString(StringBuilder toAppendTo, String in, AnsiElement element) { toAppendTo.append(AnsiOutput.toString(element, in)); } diff --git a/loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java b/loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java index c454bb153d94..3afcdd301b54 100644 --- a/loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java +++ b/loader/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java @@ -73,7 +73,7 @@ private void createFileIfNecessary(File file) throws IOException { } } - protected Properties createBuildInfo(ProjectDetails project) { + private Properties createBuildInfo(ProjectDetails project) { Properties properties = CollectionFactory.createSortedProperties(true); addIfHasValue(properties, "build.group", project.getGroup()); addIfHasValue(properties, "build.artifact", project.getArtifact());