diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java index 6a9eb3b4e5..0c25cfce38 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java @@ -87,7 +87,7 @@ public class AuditEvent implements Serializable { Assert.notNull(timestamp, "Timestamp must not be null"); Assert.notNull(type, "Type must not be null"); this.timestamp = timestamp; - this.principal = principal != null ? principal : ""; + this.principal = (principal != null ? principal : ""); this.type = type; this.data = Collections.unmodifiableMap(data); } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java index bf01b5a54e..8bb06dc9fb 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java @@ -16,8 +16,9 @@ package org.springframework.boot.cli; -import java.util.Arrays; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import org.springframework.boot.cli.command.Command; @@ -38,14 +39,24 @@ import org.springframework.boot.cli.command.run.RunCommand; */ public class DefaultCommandFactory implements CommandFactory { - private static final List defaultCommands = Arrays.asList( - new VersionCommand(), new RunCommand(), new GrabCommand(), new JarCommand(), - new WarCommand(), new InstallCommand(), new UninstallCommand(), - new InitCommand()); + private static final List DEFAULT_COMMANDS; + + static { + ArrayList defaultCommands = new ArrayList<>(); + defaultCommands.add(new VersionCommand()); + defaultCommands.add(new RunCommand()); + defaultCommands.add(new GrabCommand()); + defaultCommands.add(new JarCommand()); + defaultCommands.add(new WarCommand()); + defaultCommands.add(new InstallCommand()); + defaultCommands.add(new UninstallCommand()); + defaultCommands.add(new InitCommand()); + DEFAULT_COMMANDS = Collections.unmodifiableList(defaultCommands); + } @Override public Collection getCommands() { - return defaultCommands; + return DEFAULT_COMMANDS; } } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java index a8429f77ab..ed1edba0fb 100755 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java @@ -42,7 +42,7 @@ import org.springframework.core.env.PropertySource; @Order(Ordered.LOWEST_PRECEDENCE) public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor { - private static final Map properties; + private static final Map PROPERTIES; static { Map devToolsProperties = new HashMap<>(); @@ -58,7 +58,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro devToolsProperties.put("spring.mvc.log-resolved-exception", "true"); devToolsProperties.put("server.servlet.jsp.init-parameters.development", "true"); devToolsProperties.put("spring.reactor.stacktrace-mode.enabled", "true"); - properties = Collections.unmodifiableMap(devToolsProperties); + PROPERTIES = Collections.unmodifiableMap(devToolsProperties); } @Override @@ -66,7 +66,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro SpringApplication application) { if (isLocalApplication(environment) && canAddProperties(environment)) { PropertySource propertySource = new MapPropertySource("refresh", - properties); + PROPERTIES); environment.getPropertySources().addLast(propertySource); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index 82f68d3b46..a5c241e0ee 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -228,14 +228,14 @@ class ImportsContextCustomizer implements ContextCustomizer { private static final Class[] NO_IMPORTS = {}; - private static final Set annotationFilters; + private static final Set ANNOTATION_FILTERS; static { Set filters = new HashSet<>(); filters.add(new JavaLangAnnotationFilter()); filters.add(new KotlinAnnotationFilter()); filters.add(new SpockAnnotationFilter()); - annotationFilters = Collections.unmodifiableSet(filters); + ANNOTATION_FILTERS = Collections.unmodifiableSet(filters); } private final Set key; @@ -274,7 +274,7 @@ class ImportsContextCustomizer implements ContextCustomizer { } private boolean isIgnoredAnnotation(Annotation annotation) { - for (AnnotationFilter annotationFilter : annotationFilters) { + for (AnnotationFilter annotationFilter : ANNOTATION_FILTERS) { if (annotationFilter.isIgnored(annotation)) { return true; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java index 75d659f570..4e92f8a182 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java @@ -55,7 +55,6 @@ public final class JsonContent implements AssertProvider { /** * Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat} * instead. - * * @deprecated in favor of AssertJ's {@link org.assertj.core.api.Assertions#assertThat * assertThat} */ diff --git a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java index 7db8761ec0..aae167b12c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java @@ -177,7 +177,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor { return result; } - private Object processValue(Object value) { + private Object processValue(Object value) { if (value instanceof DeclaredType) { return getQualifiedName(((DeclaredType) value).asElement()); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java index 3efcb2c988..e2d1a9c610 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java @@ -121,7 +121,7 @@ public final class Layouts { */ public static class War implements Layout { - private static final Map scopeDestinations; + private static final Map SCOPE_DESTINATIONS; static { Map map = new HashMap<>(); @@ -129,7 +129,7 @@ public final class Layouts { map.put(LibraryScope.CUSTOM, "WEB-INF/lib/"); map.put(LibraryScope.RUNTIME, "WEB-INF/lib/"); map.put(LibraryScope.PROVIDED, "WEB-INF/lib-provided/"); - scopeDestinations = Collections.unmodifiableMap(map); + SCOPE_DESTINATIONS = Collections.unmodifiableMap(map); } @Override @@ -139,7 +139,7 @@ public final class Layouts { @Override public String getLibraryDestination(String libraryName, LibraryScope scope) { - return scopeDestinations.get(scope); + return SCOPE_DESTINATIONS.get(scope); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ArtifactsLibraries.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ArtifactsLibraries.java index 5ed0dbe765..ec7c7df907 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ArtifactsLibraries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ArtifactsLibraries.java @@ -42,7 +42,7 @@ import org.springframework.boot.loader.tools.LibraryScope; */ public class ArtifactsLibraries implements Libraries { - private static final Map scopes; + private static final Map SCOPES; static { Map libraryScopes = new HashMap<>(); @@ -50,7 +50,7 @@ public class ArtifactsLibraries implements Libraries { libraryScopes.put(Artifact.SCOPE_RUNTIME, LibraryScope.RUNTIME); libraryScopes.put(Artifact.SCOPE_PROVIDED, LibraryScope.PROVIDED); libraryScopes.put(Artifact.SCOPE_SYSTEM, LibraryScope.PROVIDED); - scopes = Collections.unmodifiableMap(libraryScopes); + SCOPES = Collections.unmodifiableMap(libraryScopes); } private final Set artifacts; @@ -70,7 +70,7 @@ public class ArtifactsLibraries implements Libraries { public void doWithLibraries(LibraryCallback callback) throws IOException { Set duplicates = getDuplicates(this.artifacts); for (Artifact artifact : this.artifacts) { - LibraryScope scope = scopes.get(artifact.getScope()); + LibraryScope scope = SCOPES.get(artifact.getScope()); if (scope != null && artifact.getFile() != null) { String name = getFileName(artifact); if (duplicates.contains(name)) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java index eeaa971cc4..9a085632ea 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java @@ -106,7 +106,7 @@ public enum EmbeddedDatabaseConnection { */ public String getUrl(String databaseName) { Assert.hasText(databaseName, "DatabaseName must not be null."); - return this.url != null ? String.format(this.url, databaseName) : null; + return (this.url != null ? String.format(this.url, databaseName) : null); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 3f6340fea1..15176f2986 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -49,7 +49,7 @@ import org.springframework.boot.ansi.AnsiStyle; @ConverterKeys({ "clr", "color" }) public final class ColorConverter extends LogEventPatternConverter { - private static final Map elements; + private static final Map ELEMENTS; static { Map ansiElements = new HashMap<>(); @@ -60,17 +60,17 @@ public final class ColorConverter extends LogEventPatternConverter { ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("cyan", AnsiColor.CYAN); - elements = Collections.unmodifiableMap(ansiElements); + ELEMENTS = Collections.unmodifiableMap(ansiElements); } - private static final Map levels; + private static final Map LEVELS; static { Map ansiLevels = new HashMap<>(); ansiLevels.put(Level.FATAL.intLevel(), AnsiColor.RED); ansiLevels.put(Level.ERROR.intLevel(), AnsiColor.RED); ansiLevels.put(Level.WARN.intLevel(), AnsiColor.YELLOW); - levels = Collections.unmodifiableMap(ansiLevels); + LEVELS = Collections.unmodifiableMap(ansiLevels); } private final List formatters; @@ -101,7 +101,7 @@ public final class ColorConverter extends LogEventPatternConverter { } PatternParser parser = PatternLayout.createPatternParser(config); List formatters = parser.parse(options[0]); - AnsiElement element = (options.length == 1 ? null : elements.get(options[1])); + AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1])); return new ColorConverter(formatters, element); } @@ -125,7 +125,7 @@ public final class ColorConverter extends LogEventPatternConverter { AnsiElement element = this.styling; if (element == null) { // Assume highlighting - element = levels.get(event.getLevel().intLevel()); + element = LEVELS.get(event.getLevel().intLevel()); element = (element == null ? AnsiColor.GREEN : element); } appendAnsiString(toAppendTo, buf.toString(), element); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java index 470646f3fc..a73c2f57b1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java @@ -38,7 +38,7 @@ import org.springframework.boot.ansi.AnsiStyle; */ public class ColorConverter extends CompositeConverter { - private static final Map elements; + private static final Map ELEMENTS; static { Map ansiElements = new HashMap<>(); @@ -49,24 +49,24 @@ public class ColorConverter extends CompositeConverter { ansiElements.put("blue", AnsiColor.BLUE); ansiElements.put("magenta", AnsiColor.MAGENTA); ansiElements.put("cyan", AnsiColor.CYAN); - elements = Collections.unmodifiableMap(ansiElements); + ELEMENTS = Collections.unmodifiableMap(ansiElements); } - private static final Map levels; + private static final Map LEVELS; static { Map ansiLevels = new HashMap<>(); ansiLevels.put(Level.ERROR_INTEGER, AnsiColor.RED); ansiLevels.put(Level.WARN_INTEGER, AnsiColor.YELLOW); - levels = Collections.unmodifiableMap(ansiLevels); + LEVELS = Collections.unmodifiableMap(ansiLevels); } @Override protected String transform(ILoggingEvent event, String in) { - AnsiElement element = elements.get(getFirstOption()); + AnsiElement element = ELEMENTS.get(getFirstOption()); if (element == null) { // Assume highlighting - element = levels.get(event.getLevel().toInteger()); + element = LEVELS.get(event.getLevel().toInteger()); element = (element == null ? AnsiColor.GREEN : element); } return toAnsiString(in, element); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java index 67da5c258c..726a32a06e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java @@ -66,23 +66,23 @@ public class ApplicationPidFileWriter private static final String DEFAULT_FILE_NAME = "application.pid"; - private static final List fileProperties; + private static final List FILE_PROPERTIES; static { List properties = new ArrayList<>(); properties.add(new SpringProperty("spring.pid.", "file")); properties.add(new SpringProperty("spring.", "pidfile")); properties.add(new SystemProperty("PIDFILE")); - fileProperties = Collections.unmodifiableList(properties); + FILE_PROPERTIES = Collections.unmodifiableList(properties); } - private static final List failOnWriteErrorProperties; + private static final List FAIL_ON_WRITE_ERROR_PROPERTIES; static { List properties = new ArrayList<>(); properties.add(new SpringProperty("spring.pid.", "fail-on-write-error")); properties.add(new SystemProperty("PID_FAIL_ON_WRITE_ERROR")); - failOnWriteErrorProperties = Collections.unmodifiableList(properties); + FAIL_ON_WRITE_ERROR_PROPERTIES = Collections.unmodifiableList(properties); } private static final AtomicBoolean created = new AtomicBoolean(false); @@ -153,7 +153,7 @@ public class ApplicationPidFileWriter private void writePidFile(SpringApplicationEvent event) throws IOException { File pidFile = this.file; - String override = getProperty(event, fileProperties); + String override = getProperty(event, FILE_PROPERTIES); if (override != null) { pidFile = new File(override); } @@ -162,7 +162,7 @@ public class ApplicationPidFileWriter } private boolean failOnWriteError(SpringApplicationEvent event) { - String value = getProperty(event, failOnWriteErrorProperties); + String value = getProperty(event, FAIL_ON_WRITE_ERROR_PROPERTIES); return (value == null ? false : Boolean.parseBoolean(value)); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java index e6667e65c4..90fecb838d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java @@ -43,14 +43,14 @@ import org.springframework.web.context.WebApplicationContext; class ServletComponentRegisteringPostProcessor implements BeanFactoryPostProcessor, ApplicationContextAware { - private static final List handlers; + private static final List HANDLERS; static { List servletComponentHandlers = new ArrayList<>(); servletComponentHandlers.add(new WebServletHandler()); servletComponentHandlers.add(new WebFilterHandler()); servletComponentHandlers.add(new WebListenerHandler()); - handlers = Collections.unmodifiableList(servletComponentHandlers); + HANDLERS = Collections.unmodifiableList(servletComponentHandlers); } private final Set packagesToScan; @@ -78,7 +78,7 @@ class ServletComponentRegisteringPostProcessor for (BeanDefinition candidate : componentProvider .findCandidateComponents(packageToScan)) { if (candidate instanceof ScannedGenericBeanDefinition) { - for (ServletComponentHandler handler : handlers) { + for (ServletComponentHandler handler : HANDLERS) { handler.handle(((ScannedGenericBeanDefinition) candidate), (BeanDefinitionRegistry) this.applicationContext); } @@ -97,7 +97,7 @@ class ServletComponentRegisteringPostProcessor false); componentProvider.setEnvironment(this.applicationContext.getEnvironment()); componentProvider.setResourceLoader(this.applicationContext); - for (ServletComponentHandler handler : handlers) { + for (ServletComponentHandler handler : HANDLERS) { componentProvider.addIncludeFilter(handler.getTypeFilter()); } return componentProvider; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBean.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBean.java index 6cef047dad..a26d5d84c1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBean.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBean.java @@ -19,6 +19,7 @@ package org.springframework.boot.web.servlet; import java.util.Collections; import java.util.EventListener; import java.util.HashSet; +import java.util.Map; import java.util.Set; import javax.servlet.ServletContext; @@ -104,6 +105,75 @@ public class ServletListenerRegistrationBean this.listener = listener; } + /** + * Set the name of this registration. If not specified the bean name will be used. + * @param name the name of the registration + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public void setName(String name) { + super.setName(name); + } + + /** + * Sets if asynchronous operations are support for this registration. If not specified + * defaults to {@code true}. + * @param asyncSupported if async is supported + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public void setAsyncSupported(boolean asyncSupported) { + super.setAsyncSupported(asyncSupported); + } + + /** + * Returns if asynchronous operations are support for this registration. + * @return if async is supported + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public boolean isAsyncSupported() { + return super.isAsyncSupported(); + } + + /** + * Set init-parameters for this registration. Calling this method will replace any + * existing init-parameters. + * @param initParameters the init parameters + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public void setInitParameters(Map initParameters) { + super.setInitParameters(initParameters); + } + + /** + * Returns a mutable Map of the registration init-parameters. + * @return the init parameters + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public Map getInitParameters() { + return super.getInitParameters(); + } + + /** + * Add a single init-parameter, replacing any existing parameter with the same name. + * @param name the init-parameter name + * @param value the init-parameter value + * @deprecated as of 1.5 since not applicable to listeners + */ + @Override + @Deprecated + public void addInitParameter(String name, String value) { + super.addInitParameter(name, value); + } + @Override public void onStartup(ServletContext servletContext) throws ServletException { if (!isEnabled()) {