Merge pull request #25986 from dreis2211

* pr/25986:
  Update copyright year of changed file
  Remove unused method parameters

Closes gh-25986
pull/26041/head
Stephane Nicoll 4 years ago
commit b9bfc1523f

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2021 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -110,7 +110,7 @@ class AsciidoctorConventions {
asciidoctorTask.baseDirFollowsSourceDir(); asciidoctorTask.baseDirFollowsSourceDir();
createSyncDocumentationSourceTask(project, asciidoctorTask); createSyncDocumentationSourceTask(project, asciidoctorTask);
if (asciidoctorTask instanceof AsciidoctorTask) { if (asciidoctorTask instanceof AsciidoctorTask) {
configureAsciidoctorHtmlTask(project, (AsciidoctorTask) asciidoctorTask); configureAsciidoctorHtmlTask((AsciidoctorTask) asciidoctorTask);
} }
} }
@ -144,7 +144,7 @@ class AsciidoctorConventions {
return syncDocumentationSource; return syncDocumentationSource;
} }
private void configureAsciidoctorHtmlTask(Project project, AsciidoctorTask asciidoctorTask) { private void configureAsciidoctorHtmlTask(AsciidoctorTask asciidoctorTask) {
asciidoctorTask.outputOptions((outputOptions) -> outputOptions.backends("spring-html")); asciidoctorTask.outputOptions((outputOptions) -> outputOptions.backends("spring-html"));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import org.gradle.api.attributes.Usage;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension; import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.VariantVersionMappingStrategy;
import org.gradle.api.publish.maven.MavenPom; import org.gradle.api.publish.maven.MavenPom;
import org.gradle.api.publish.maven.MavenPomDeveloperSpec; import org.gradle.api.publish.maven.MavenPomDeveloperSpec;
import org.gradle.api.publish.maven.MavenPomIssueManagement; import org.gradle.api.publish.maven.MavenPomIssueManagement;
@ -78,8 +79,7 @@ class MavenPublishingConventions {
private void customizeMavenPublication(MavenPublication publication, Project project) { private void customizeMavenPublication(MavenPublication publication, Project project) {
customizePom(publication.getPom(), project); customizePom(publication.getPom(), project);
project.getPlugins().withType(JavaPlugin.class) project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> customizeJavaMavenPublication(publication));
.all((javaPlugin) -> customizeJavaMavenPublication(publication, project));
} }
private void customizePom(MavenPom pom, Project project) { private void customizePom(MavenPom pom, Project project) {
@ -97,11 +97,11 @@ class MavenPublishingConventions {
} }
} }
private void customizeJavaMavenPublication(MavenPublication publication, Project project) { private void customizeJavaMavenPublication(MavenPublication publication) {
publication.versionMapping((strategy) -> strategy.usage(Usage.JAVA_API, (mappingStrategy) -> mappingStrategy publication.versionMapping((strategy) -> strategy.usage(Usage.JAVA_API, (mappingStrategy) -> mappingStrategy
.fromResolutionOf(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME))); .fromResolutionOf(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
publication.versionMapping((strategy) -> strategy.usage(Usage.JAVA_RUNTIME, publication.versionMapping(
(mappingStrategy) -> mappingStrategy.fromResolutionResult())); (strategy) -> strategy.usage(Usage.JAVA_RUNTIME, VariantVersionMappingStrategy::fromResolutionResult));
} }
private void customizeOrganization(MavenPomOrganization organization) { private void customizeOrganization(MavenPomOrganization organization) {

@ -49,7 +49,6 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -63,8 +62,7 @@ import org.springframework.util.StringUtils;
@Deprecated @Deprecated
class DataSourceInitializationConfiguration { class DataSourceInitializationConfiguration {
private static DataSource determineDataSource(Supplier<DataSource> dataSource, String username, String password, private static DataSource determineDataSource(Supplier<DataSource> dataSource, String username, String password) {
DataSourceProperties properties) {
if (StringUtils.hasText(username) && StringUtils.hasText(password)) { if (StringUtils.hasText(username) && StringUtils.hasText(password)) {
DataSourceBuilder.derivedFrom(dataSource.get()).type(SimpleDriverDataSource.class).username(username) DataSourceBuilder.derivedFrom(dataSource.get()).type(SimpleDriverDataSource.class).username(username)
.password(password).build(); .password(password).build();
@ -92,14 +90,14 @@ class DataSourceInitializationConfiguration {
@Bean @Bean
DataSourceScriptDatabaseInitializer ddlOnlyScriptDataSourceInitializer(ObjectProvider<DataSource> dataSource, DataSourceScriptDatabaseInitializer ddlOnlyScriptDataSourceInitializer(ObjectProvider<DataSource> dataSource,
DataSourceProperties properties, ResourceLoader resourceLoader) { DataSourceProperties properties) {
DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); DatabaseInitializationSettings settings = new DatabaseInitializationSettings();
settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform())); settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform()));
settings.setContinueOnError(properties.isContinueOnError()); settings.setContinueOnError(properties.isContinueOnError());
settings.setSeparator(properties.getSeparator()); settings.setSeparator(properties.getSeparator());
settings.setEncoding(properties.getSqlScriptEncoding()); settings.setEncoding(properties.getSqlScriptEncoding());
DataSource initializationDataSource = determineDataSource(dataSource::getObject, DataSource initializationDataSource = determineDataSource(dataSource::getObject,
properties.getSchemaUsername(), properties.getSchemaPassword(), properties); properties.getSchemaUsername(), properties.getSchemaPassword());
return new InitializationModeDataSourceScriptDatabaseInitializer(initializationDataSource, settings, return new InitializationModeDataSourceScriptDatabaseInitializer(initializationDataSource, settings,
properties.getInitializationMode()); properties.getInitializationMode());
} }
@ -107,14 +105,14 @@ class DataSourceInitializationConfiguration {
@Bean @Bean
@DependsOn("ddlOnlyScriptDataSourceInitializer") @DependsOn("ddlOnlyScriptDataSourceInitializer")
DataSourceScriptDatabaseInitializer dmlOnlyScriptDataSourceInitializer(ObjectProvider<DataSource> dataSource, DataSourceScriptDatabaseInitializer dmlOnlyScriptDataSourceInitializer(ObjectProvider<DataSource> dataSource,
DataSourceProperties properties, ResourceLoader resourceLoader) { DataSourceProperties properties) {
DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); DatabaseInitializationSettings settings = new DatabaseInitializationSettings();
settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform())); settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform()));
settings.setContinueOnError(properties.isContinueOnError()); settings.setContinueOnError(properties.isContinueOnError());
settings.setSeparator(properties.getSeparator()); settings.setSeparator(properties.getSeparator());
settings.setEncoding(properties.getSqlScriptEncoding()); settings.setEncoding(properties.getSqlScriptEncoding());
DataSource initializationDataSource = determineDataSource(dataSource::getObject, DataSource initializationDataSource = determineDataSource(dataSource::getObject,
properties.getDataUsername(), properties.getDataPassword(), properties); properties.getDataUsername(), properties.getDataPassword());
return new InitializationModeDataSourceScriptDatabaseInitializer(initializationDataSource, settings, return new InitializationModeDataSourceScriptDatabaseInitializer(initializationDataSource, settings,
properties.getInitializationMode()); properties.getInitializationMode());
} }
@ -149,7 +147,7 @@ class DataSourceInitializationConfiguration {
@Bean @Bean
DataSourceScriptDatabaseInitializer scriptDataSourceInitializer(DataSource dataSource, DataSourceScriptDatabaseInitializer scriptDataSourceInitializer(DataSource dataSource,
DataSourceProperties properties, ResourceLoader resourceLoader) { DataSourceProperties properties) {
DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); DatabaseInitializationSettings settings = new DatabaseInitializationSettings();
settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform())); settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform()));
settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform())); settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform()));

@ -217,7 +217,7 @@ class ConfigDataEnvironmentContributors implements Iterable<ConfigDataEnvironmen
private Binder getBinder(ConfigDataActivationContext activationContext, private Binder getBinder(ConfigDataActivationContext activationContext,
Predicate<ConfigDataEnvironmentContributor> filter, Set<BinderOption> options) { Predicate<ConfigDataEnvironmentContributor> filter, Set<BinderOption> options) {
boolean failOnInactiveSource = options.contains(BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE); boolean failOnInactiveSource = options.contains(BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE);
Iterable<ConfigurationPropertySource> sources = () -> getBinderSources(activationContext, Iterable<ConfigurationPropertySource> sources = () -> getBinderSources(
filter.and((contributor) -> failOnInactiveSource || contributor.isActive(activationContext))); filter.and((contributor) -> failOnInactiveSource || contributor.isActive(activationContext)));
PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(this.root, PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(this.root,
activationContext, failOnInactiveSource); activationContext, failOnInactiveSource);
@ -225,8 +225,7 @@ class ConfigDataEnvironmentContributors implements Iterable<ConfigDataEnvironmen
return new Binder(sources, placeholdersResolver, null, null, bindHandler); return new Binder(sources, placeholdersResolver, null, null, bindHandler);
} }
private Iterator<ConfigurationPropertySource> getBinderSources(ConfigDataActivationContext activationContext, private Iterator<ConfigurationPropertySource> getBinderSources(Predicate<ConfigDataEnvironmentContributor> filter) {
Predicate<ConfigDataEnvironmentContributor> filter) {
return this.root.stream().filter(this::hasConfigurationPropertySource).filter(filter) return this.root.stream().filter(this::hasConfigurationPropertySource).filter(filter)
.map(ConfigDataEnvironmentContributor::getConfigurationPropertySource).iterator(); .map(ConfigDataEnvironmentContributor::getConfigurationPropertySource).iterator();
} }

@ -57,11 +57,6 @@ class ConfigDataProperties {
* @param activate the activate properties * @param activate the activate properties
*/ */
ConfigDataProperties(@Name("import") List<ConfigDataLocation> imports, Activate activate) { ConfigDataProperties(@Name("import") List<ConfigDataLocation> imports, Activate activate) {
this(imports, activate, Collections.emptyList());
}
private ConfigDataProperties(List<ConfigDataLocation> imports, Activate activate,
List<ConfigurationProperty> boundProperties) {
this.imports = (imports != null) ? imports : Collections.emptyList(); this.imports = (imports != null) ? imports : Collections.emptyList();
this.activate = activate; this.activate = activate;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,15 +52,14 @@ public class ConfigTreeConfigDataLocationResolver implements ConfigDataLocationR
public List<ConfigTreeConfigDataResource> resolve(ConfigDataLocationResolverContext context, public List<ConfigTreeConfigDataResource> resolve(ConfigDataLocationResolverContext context,
ConfigDataLocation location) { ConfigDataLocation location) {
try { try {
return resolve(context, location.getNonPrefixedValue(PREFIX)); return resolve(location.getNonPrefixedValue(PREFIX));
} }
catch (IOException ex) { catch (IOException ex) {
throw new ConfigDataLocationNotFoundException(location, ex); throw new ConfigDataLocationNotFoundException(location, ex);
} }
} }
private List<ConfigTreeConfigDataResource> resolve(ConfigDataLocationResolverContext context, String location) private List<ConfigTreeConfigDataResource> resolve(String location) throws IOException {
throws IOException {
Assert.isTrue(location.endsWith("/"), Assert.isTrue(location.endsWith("/"),
() -> String.format("Config tree location '%s' must end with '/'", location)); () -> String.format("Config tree location '%s' must end with '/'", location));
if (!this.resourceLoader.isPattern(location)) { if (!this.resourceLoader.isPattern(location)) {

@ -753,7 +753,7 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
ElementType[] type = new ElementType[size]; ElementType[] type = new ElementType[size];
System.arraycopy(this.type, 0, type, 0, this.size); System.arraycopy(this.type, 0, type, 0, this.size);
System.arraycopy(additional.type, 0, type, this.size, additional.size); System.arraycopy(additional.type, 0, type, this.size, additional.size);
CharSequence[] resolved = newResolved(0, size); CharSequence[] resolved = newResolved(size);
for (int i = 0; i < additional.size; i++) { for (int i = 0; i < additional.size; i++) {
resolved[this.size + i] = additional.get(i); resolved[this.size + i] = additional.get(i);
} }
@ -761,13 +761,13 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
} }
Elements chop(int size) { Elements chop(int size) {
CharSequence[] resolved = newResolved(0, size); CharSequence[] resolved = newResolved(size);
return new Elements(this.source, size, this.start, this.end, this.type, resolved); return new Elements(this.source, size, this.start, this.end, this.type, resolved);
} }
Elements subElements(int offset) { Elements subElements(int offset) {
int size = this.size - offset; int size = this.size - offset;
CharSequence[] resolved = newResolved(offset, size); CharSequence[] resolved = newResolved(size);
int[] start = new int[size]; int[] start = new int[size];
System.arraycopy(this.start, offset, start, 0, size); System.arraycopy(this.start, offset, start, 0, size);
int[] end = new int[size]; int[] end = new int[size];
@ -777,7 +777,7 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
return new Elements(this.source, size, start, end, type, resolved); return new Elements(this.source, size, start, end, type, resolved);
} }
private CharSequence[] newResolved(int offset, int size) { private CharSequence[] newResolved(int size) {
CharSequence[] resolved = new CharSequence[size]; CharSequence[] resolved = new CharSequence[size];
if (this.resolved != null) { if (this.resolved != null) {
System.arraycopy(this.resolved, 0, resolved, 0, Math.min(size, this.size)); System.arraycopy(this.resolved, 0, resolved, 0, Math.min(size, this.size));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,10 +86,10 @@ public class EnvironmentPostProcessorApplicationListener implements SmartApplica
onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event); onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event);
} }
if (event instanceof ApplicationPreparedEvent) { if (event instanceof ApplicationPreparedEvent) {
onApplicationPreparedEvent((ApplicationPreparedEvent) event); onApplicationPreparedEvent();
} }
if (event instanceof ApplicationFailedEvent) { if (event instanceof ApplicationFailedEvent) {
onApplicationFailedEvent((ApplicationFailedEvent) event); onApplicationFailedEvent();
} }
} }
@ -101,11 +101,11 @@ public class EnvironmentPostProcessorApplicationListener implements SmartApplica
} }
} }
private void onApplicationPreparedEvent(ApplicationPreparedEvent event) { private void onApplicationPreparedEvent() {
finish(); finish();
} }
private void onApplicationFailedEvent(ApplicationFailedEvent event) { private void onApplicationFailedEvent() {
finish(); finish();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import ch.qos.logback.core.util.FileSize;
import ch.qos.logback.core.util.OptionHelper; import ch.qos.logback.core.util.OptionHelper;
import org.springframework.boot.logging.LogFile; import org.springframework.boot.logging.LogFile;
import org.springframework.boot.logging.LoggingInitializationContext;
/** /**
* Default logback configuration used by Spring Boot. Uses {@link LogbackConfigurator} to * Default logback configuration used by Spring Boot. Uses {@link LogbackConfigurator} to
@ -46,7 +45,7 @@ class DefaultLogbackConfiguration {
private final LogFile logFile; private final LogFile logFile;
DefaultLogbackConfiguration(LoggingInitializationContext initializationContext, LogFile logFile) { DefaultLogbackConfiguration(LogFile logFile) {
this.logFile = logFile; this.logFile = logFile;
} }
@ -106,13 +105,12 @@ class DefaultLogbackConfiguration {
appender.setEncoder(encoder); appender.setEncoder(encoder);
config.start(encoder); config.start(encoder);
appender.setFile(logFile); appender.setFile(logFile);
setRollingPolicy(appender, config, logFile); setRollingPolicy(appender, config);
config.appender("FILE", appender); config.appender("FILE", appender);
return appender; return appender;
} }
private void setRollingPolicy(RollingFileAppender<ILoggingEvent> appender, LogbackConfigurator config, private void setRollingPolicy(RollingFileAppender<ILoggingEvent> appender, LogbackConfigurator config) {
String logFile) {
SizeAndTimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new SizeAndTimeBasedRollingPolicy<>(); SizeAndTimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new SizeAndTimeBasedRollingPolicy<>();
rollingPolicy.setContext(config.getContext()); rollingPolicy.setContext(config.getContext());
rollingPolicy.setFileNamePattern( rollingPolicy.setFileNamePattern(

@ -151,7 +151,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
new LogbackLoggingSystemProperties(environment, context::putProperty).apply(logFile); new LogbackLoggingSystemProperties(environment, context::putProperty).apply(logFile);
LogbackConfigurator configurator = debug ? new DebugLogbackConfigurator(context) LogbackConfigurator configurator = debug ? new DebugLogbackConfigurator(context)
: new LogbackConfigurator(context); : new LogbackConfigurator(context);
new DefaultLogbackConfiguration(initializationContext, logFile).apply(configurator); new DefaultLogbackConfiguration(logFile).apply(configurator);
context.setPackagingDataEnabled(true); context.setPackagingDataEnabled(true);
} }

Loading…
Cancel
Save