Polish
This commit is contained in:
@@ -53,8 +53,6 @@ class ReactiveCloudFoundrySecurityService {
|
||||
|
||||
private final String cloudControllerUrl;
|
||||
|
||||
private Mono<String> uaaUrl;
|
||||
|
||||
ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl,
|
||||
boolean skipSslValidation) {
|
||||
Assert.notNull(webClientBuilder, "WebClient must not be null");
|
||||
@@ -149,7 +147,7 @@ class ReactiveCloudFoundrySecurityService {
|
||||
* @return the UAA url Mono
|
||||
*/
|
||||
Mono<String> getUaaUrl() {
|
||||
this.uaaUrl = this.webClient.get()
|
||||
return this.webClient.get()
|
||||
.uri(this.cloudControllerUrl + "/info")
|
||||
.retrieve()
|
||||
.bodyToMono(Map.class)
|
||||
@@ -157,7 +155,6 @@ class ReactiveCloudFoundrySecurityService {
|
||||
.cache()
|
||||
.onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
|
||||
"Unable to fetch token keys from UAA."));
|
||||
return this.uaaUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -86,7 +86,7 @@ class CloudFoundrySecurityInterceptor {
|
||||
return SecurityResponse.success();
|
||||
}
|
||||
|
||||
private void check(HttpServletRequest request, EndpointId endpointId) throws Exception {
|
||||
private void check(HttpServletRequest request, EndpointId endpointId) {
|
||||
Token token = getToken(request);
|
||||
this.tokenValidator.validate(token);
|
||||
AccessLevel accessLevel = this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId);
|
||||
|
||||
@@ -143,11 +143,8 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
|
||||
}
|
||||
|
||||
private Boolean isEnabledByDefault(Environment environment) {
|
||||
Optional<Boolean> enabledByDefault = enabledByDefaultCache.get(environment);
|
||||
if (enabledByDefault == null) {
|
||||
enabledByDefault = Optional.ofNullable(environment.getProperty(ENABLED_BY_DEFAULT_KEY, Boolean.class));
|
||||
enabledByDefaultCache.put(environment, enabledByDefault);
|
||||
}
|
||||
Optional<Boolean> enabledByDefault = enabledByDefaultCache.computeIfAbsent(environment,
|
||||
(ignore) -> Optional.ofNullable(environment.getProperty(ENABLED_BY_DEFAULT_KEY, Boolean.class)));
|
||||
return enabledByDefault.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class IncludeExcludeEndpointFilter<E extends ExposableEndpoint<?>> implem
|
||||
private final Set<EndpointId> endpointIds;
|
||||
|
||||
EndpointPatterns(String[] patterns) {
|
||||
this((patterns != null) ? Arrays.asList(patterns) : (Collection<String>) null);
|
||||
this((patterns != null) ? Arrays.asList(patterns) : null);
|
||||
}
|
||||
|
||||
EndpointPatterns(Collection<String> patterns) {
|
||||
|
||||
@@ -60,8 +60,8 @@ public final class ManagementContextFactory {
|
||||
Environment parentEnvironment = parentContext.getEnvironment();
|
||||
ConfigurableEnvironment childEnvironment = ApplicationContextFactory.DEFAULT
|
||||
.createEnvironment(this.webApplicationType);
|
||||
if (parentEnvironment instanceof ConfigurableEnvironment) {
|
||||
childEnvironment.setConversionService(((ConfigurableEnvironment) parentEnvironment).getConversionService());
|
||||
if (parentEnvironment instanceof ConfigurableEnvironment configurableEnvironment) {
|
||||
childEnvironment.setConversionService((configurableEnvironment).getConversionService());
|
||||
}
|
||||
ConfigurableApplicationContext managementContext = ApplicationContextFactory.DEFAULT
|
||||
.create(this.webApplicationType);
|
||||
|
||||
@@ -217,8 +217,8 @@ class ChildManagementContextInitializer
|
||||
}
|
||||
|
||||
static void addIfPossible(ApplicationContext parentContext, ConfigurableApplicationContext childContext) {
|
||||
if (parentContext instanceof ConfigurableApplicationContext) {
|
||||
add((ConfigurableApplicationContext) parentContext, childContext);
|
||||
if (parentContext instanceof ConfigurableApplicationContext configurableApplicationContext) {
|
||||
add(configurableApplicationContext, childContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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,7 +101,7 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
|
||||
}
|
||||
}
|
||||
|
||||
private void doDataSourceHealthCheck(Health.Builder builder) throws Exception {
|
||||
private void doDataSourceHealthCheck(Health.Builder builder) {
|
||||
builder.up().withDetail("database", getProduct());
|
||||
String validationQuery = this.query;
|
||||
if (StringUtils.hasText(validationQuery)) {
|
||||
|
||||
@@ -60,7 +60,7 @@ class ShutdownEndpointTests {
|
||||
Thread.currentThread().setContextClassLoader(previousTccl);
|
||||
}
|
||||
assertThat(result.getMessage()).startsWith("Shutting down");
|
||||
assertThat(((ConfigurableApplicationContext) context).isActive()).isTrue();
|
||||
assertThat(context.isActive()).isTrue();
|
||||
assertThat(config.latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(config.threadContextClassLoader).isEqualTo(getClass().getClassLoader());
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ public class BatchAutoConfiguration {
|
||||
@ConditionalOnMissingBean(JobOperator.class)
|
||||
public SimpleJobOperator jobOperator(ObjectProvider<JobParametersConverter> jobParametersConverter,
|
||||
JobExplorer jobExplorer, JobLauncher jobLauncher, ListableJobLocator jobRegistry,
|
||||
JobRepository jobRepository) throws Exception {
|
||||
JobRepository jobRepository) {
|
||||
SimpleJobOperator factory = new SimpleJobOperator();
|
||||
factory.setJobExplorer(jobExplorer);
|
||||
factory.setJobLauncher(jobLauncher);
|
||||
|
||||
@@ -61,7 +61,7 @@ class CouchbaseDataConfiguration {
|
||||
@ConditionalOnMissingBean(name = BeanNames.COUCHBASE_MAPPING_CONTEXT)
|
||||
CouchbaseMappingContext couchbaseMappingContext(CouchbaseDataProperties properties,
|
||||
ApplicationContext applicationContext, CouchbaseCustomConversions couchbaseCustomConversions)
|
||||
throws Exception {
|
||||
throws ClassNotFoundException {
|
||||
CouchbaseMappingContext mappingContext = new CouchbaseMappingContext();
|
||||
mappingContext.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class));
|
||||
mappingContext.setSimpleTypeHolder(couchbaseCustomConversions.getSimpleTypeHolder());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -80,7 +80,7 @@ class ConditionEvaluationReportLogger {
|
||||
|
||||
private void logMessage(String logLevel) {
|
||||
this.logger.info(String.format("%n%nError starting ApplicationContext. To display the "
|
||||
+ "condition evaluation report re-run your application with '" + logLevel + "' enabled."));
|
||||
+ "condition evaluation report re-run your application with '%s' enabled.", logLevel));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -92,15 +92,14 @@ public class ClassPathChangeUploader implements ApplicationListener<ClassPathCha
|
||||
try {
|
||||
ClassLoaderFiles classLoaderFiles = getClassLoaderFiles(event);
|
||||
byte[] bytes = serialize(classLoaderFiles);
|
||||
performUpload(classLoaderFiles, bytes, event);
|
||||
performUpload(bytes, event);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void performUpload(ClassLoaderFiles classLoaderFiles, byte[] bytes, ClassPathChangedEvent event)
|
||||
throws IOException {
|
||||
private void performUpload(byte[] bytes, ClassPathChangedEvent event) throws IOException {
|
||||
try {
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
@@ -187,7 +187,7 @@ public class SpringBootContextLoader extends AbstractContextLoader implements Ao
|
||||
if (mergedConfig instanceof WebMergedContextConfiguration) {
|
||||
application.setWebApplicationType(WebApplicationType.SERVLET);
|
||||
if (!isEmbeddedWebEnvironment(mergedConfig)) {
|
||||
new WebConfigurer().configure(mergedConfig, application, initializers);
|
||||
new WebConfigurer().configure(mergedConfig, initializers);
|
||||
}
|
||||
}
|
||||
else if (mergedConfig instanceof ReactiveWebMergedContextConfiguration) {
|
||||
@@ -374,8 +374,7 @@ public class SpringBootContextLoader extends AbstractContextLoader implements Ao
|
||||
*/
|
||||
private static class WebConfigurer {
|
||||
|
||||
void configure(MergedContextConfiguration mergedConfig, SpringApplication application,
|
||||
List<ApplicationContextInitializer<?>> initializers) {
|
||||
void configure(MergedContextConfiguration mergedConfig, List<ApplicationContextInitializer<?>> initializers) {
|
||||
WebMergedContextConfiguration webMergedConfig = (WebMergedContextConfiguration) mergedConfig;
|
||||
addMockServletContext(initializers, webMergedConfig);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
|
||||
@@ -204,7 +204,7 @@ class PropertyDescriptorResolver {
|
||||
MetadataGenerationEnvironment env) {
|
||||
if (constructors.size() == 1) {
|
||||
ExecutableElement candidate = constructors.get(0);
|
||||
if (candidate.getParameters().size() > 0 && !env.hasAutowiredAnnotation(candidate)) {
|
||||
if (!candidate.getParameters().isEmpty() && !env.hasAutowiredAnnotation(candidate)) {
|
||||
if (type.getNestingKind() == NestingKind.MEMBER
|
||||
&& candidate.getModifiers().contains(Modifier.PRIVATE)) {
|
||||
return null;
|
||||
|
||||
@@ -47,8 +47,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar;
|
||||
class NativeImagePluginAction implements PluginApplicationAction {
|
||||
|
||||
@Override
|
||||
public Class<? extends Plugin<? extends Project>> getPluginClass()
|
||||
throws ClassNotFoundException, NoClassDefFoundError {
|
||||
public Class<? extends Plugin<? extends Project>> getPluginClass() {
|
||||
return NativeImagePlugin.class;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -40,10 +40,10 @@ class HelpCommand extends Command {
|
||||
|
||||
@Override
|
||||
protected void run(Map<Option, String> options, List<String> parameters) {
|
||||
run(System.out, options, parameters);
|
||||
run(System.out, parameters);
|
||||
}
|
||||
|
||||
void run(PrintStream out, Map<Option, String> options, List<String> parameters) {
|
||||
void run(PrintStream out, List<String> parameters) {
|
||||
Command command = (!parameters.isEmpty()) ? Command.find(this.commands, parameters.get(0)) : null;
|
||||
if (command != null) {
|
||||
printCommandHelp(out, command);
|
||||
@@ -66,8 +66,7 @@ class HelpCommand extends Command {
|
||||
}
|
||||
|
||||
private void printOptionSummary(PrintStream out, Option option, int padding) {
|
||||
out.println(String.format(" --%-" + padding + "s %s", option.getNameAndValueDescription(),
|
||||
option.getDescription()));
|
||||
out.printf(" --%-" + padding + "s %s%n", option.getNameAndValueDescription(), option.getDescription());
|
||||
}
|
||||
|
||||
private String getUsage(Command command) {
|
||||
@@ -76,7 +75,7 @@ class HelpCommand extends Command {
|
||||
if (!command.getOptions().isEmpty()) {
|
||||
usage.append(" [options]");
|
||||
}
|
||||
command.getParameters().getDescriptions().forEach((param) -> usage.append(" " + param));
|
||||
command.getParameters().getDescriptions().forEach((param) -> usage.append(" ").append(param));
|
||||
return usage.toString();
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ class HelpCommand extends Command {
|
||||
}
|
||||
|
||||
private void printCommandSummary(PrintStream out, Command command, int padding) {
|
||||
out.println(String.format(" %-" + padding + "s %s", command.getName(), command.getDescription()));
|
||||
out.printf(" %-" + padding + "s %s%n", command.getName(), command.getDescription());
|
||||
}
|
||||
|
||||
private String getJavaCommand() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -62,13 +62,13 @@ class HelpCommandTests {
|
||||
|
||||
@Test
|
||||
void runWhenHasNoParametersPrintsUsage() {
|
||||
this.command.run(this.out, Collections.emptyMap(), Collections.emptyList());
|
||||
this.command.run(this.out, Collections.emptyList());
|
||||
assertThat(this.out).hasSameContentAsResource("help-output.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenHasNoCommandParameterPrintsUsage() {
|
||||
this.command.run(this.out, Collections.emptyMap(), Arrays.asList("extract"));
|
||||
this.command.run(this.out, Arrays.asList("extract"));
|
||||
System.out.println(this.out);
|
||||
assertThat(this.out).hasSameContentAsResource("help-extract-output.txt");
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class CustomLayersProvider {
|
||||
return new IncludeExcludeContentSelector<>(layer, includes, excludes, filterFactory);
|
||||
}
|
||||
|
||||
private <T> ContentSelector<Library> getLibrarySelector(Element element,
|
||||
private ContentSelector<Library> getLibrarySelector(Element element,
|
||||
Function<String, ContentFilter<Library>> filterFactory) {
|
||||
Layer layer = new Layer(element.getAttribute("layer"));
|
||||
List<String> includes = getChildNodeTextContent(element, "include");
|
||||
|
||||
@@ -100,15 +100,14 @@ class ConfigDataLoaders {
|
||||
private <R extends ConfigDataResource> ConfigDataLoader<R> getLoader(ConfigDataLoaderContext context, R resource) {
|
||||
ConfigDataLoader<R> result = null;
|
||||
for (int i = 0; i < this.loaders.size(); i++) {
|
||||
ConfigDataLoader<?> candidate = this.loaders.get(i);
|
||||
ConfigDataLoader<R> candidate = this.loaders.get(i);
|
||||
if (this.resourceTypes.get(i).isInstance(resource)) {
|
||||
ConfigDataLoader<R> loader = (ConfigDataLoader<R>) candidate;
|
||||
if (loader.isLoadable(context, resource)) {
|
||||
if (candidate.isLoadable(context, resource)) {
|
||||
if (result != null) {
|
||||
throw new IllegalStateException("Multiple loaders found for resource '" + resource + "' ["
|
||||
+ candidate.getClass().getName() + "," + result.getClass().getName() + "]");
|
||||
}
|
||||
result = loader;
|
||||
result = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ class NotConstructorBoundInjectionFailureAnalyzer
|
||||
InjectionPoint injectionPoint = findInjectionPoint(rootFailure);
|
||||
if (isConstructorBindingConfigurationProperties(injectionPoint)) {
|
||||
String simpleName = injectionPoint.getMember().getDeclaringClass().getSimpleName();
|
||||
String action = String.format("Update your configuration so that " + simpleName + " is defined via @"
|
||||
String action = "Update your configuration so that " + simpleName + " is defined via @"
|
||||
+ ConfigurationPropertiesScan.class.getSimpleName() + " or @"
|
||||
+ EnableConfigurationProperties.class.getSimpleName() + ".", simpleName);
|
||||
+ EnableConfigurationProperties.class.getSimpleName() + ".";
|
||||
return new FailureAnalysis(
|
||||
simpleName + " is annotated with @" + ConstructorBinding.class.getSimpleName()
|
||||
+ " but it is defined as a regular bean which caused dependency injection to fail.",
|
||||
|
||||
@@ -135,7 +135,7 @@ class DefaultBindConstructorProvider implements BindConstructorProvider {
|
||||
return new Constructor<?>[0];
|
||||
}
|
||||
return Arrays.stream(type.getDeclaredConstructors())
|
||||
.filter((constructor) -> isNonSynthetic(constructor, type))
|
||||
.filter(Constructors::isNonSynthetic)
|
||||
.toArray(Constructor[]::new);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class DefaultBindConstructorProvider implements BindConstructorProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isNonSynthetic(Constructor<?> constructor, Class<?> type) {
|
||||
private static boolean isNonSynthetic(Constructor<?> constructor) {
|
||||
return !constructor.isSynthetic();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -46,11 +46,11 @@ class BeanDefinitionOverrideFailureAnalyzer extends AbstractFailureAnalyzer<Bean
|
||||
if (ex.getBeanDefinition().getResourceDescription() != null) {
|
||||
printer.printf(", defined in %s,", ex.getBeanDefinition().getResourceDescription());
|
||||
}
|
||||
printer.printf(" could not be registered. A bean with that name has already been defined ");
|
||||
printer.print(" could not be registered. A bean with that name has already been defined ");
|
||||
if (ex.getExistingDefinition().getResourceDescription() != null) {
|
||||
printer.printf("in %s ", ex.getExistingDefinition().getResourceDescription());
|
||||
}
|
||||
printer.printf("and overriding is disabled.");
|
||||
printer.print("and overriding is disabled.");
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class MutuallyExclusiveConfigurationPropertiesFailureAnalyzer
|
||||
configuredDescriptions.forEach(message::append);
|
||||
}
|
||||
|
||||
private <S> Set<String> sortedStrings(Collection<String> input) {
|
||||
private Set<String> sortedStrings(Collection<String> input) {
|
||||
return sortedStrings(input, Function.identity());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user