Merge pull request #11812 from Igor Suhorukov
* gh-11812: Polish “Remove or use unused method parameters” Remove or use unused method parameters
This commit is contained in:
commit
10af629ec5
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -34,7 +34,7 @@ public class CloudFoundryAuthorizationException extends RuntimeException {
|
|||
|
||||
public CloudFoundryAuthorizationException(Reason reason, String message,
|
||||
Throwable cause) {
|
||||
super(message);
|
||||
super(message, cause);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ public class MappingsEndpointAutoConfiguration {
|
|||
static class SpringMvcConfiguration {
|
||||
|
||||
@Bean
|
||||
DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider(
|
||||
ApplicationContext applicationContext) {
|
||||
DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider() {
|
||||
return new DispatcherServletsMappingDescriptionProvider();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
|||
for (Map.Entry<String, Object> entry : beans.entrySet()) {
|
||||
String beanName = entry.getKey();
|
||||
Object bean = entry.getValue();
|
||||
String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean);
|
||||
String prefix = extractPrefix(context, beanFactoryMetaData, beanName);
|
||||
beanDescriptors.put(beanName, new ConfigurationPropertiesBeanDescriptor(
|
||||
prefix, sanitize(prefix, safeSerialize(mapper, bean, prefix))));
|
||||
}
|
||||
|
|
@ -201,12 +201,10 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
|||
* @param context the application context
|
||||
* @param beanFactoryMetaData the bean factory meta-data
|
||||
* @param beanName the bean name
|
||||
* @param bean the bean
|
||||
* @return the prefix
|
||||
*/
|
||||
private String extractPrefix(ApplicationContext context,
|
||||
ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName,
|
||||
Object bean) {
|
||||
ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName) {
|
||||
ConfigurationProperties annotation = context.findAnnotationOnBean(beanName,
|
||||
ConfigurationProperties.class);
|
||||
if (beanFactoryMetaData != null) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class RequestPredicateFactory {
|
|||
public WebOperationRequestPredicate getRequestPredicate(String endpointId,
|
||||
String rootPath, DiscoveredOperationMethod operationMethod) {
|
||||
Method method = operationMethod.getMethod();
|
||||
String path = getPath(endpointId, rootPath, method);
|
||||
String path = getPath(rootPath, method);
|
||||
WebEndpointHttpMethod httpMethod = determineHttpMethod(
|
||||
operationMethod.getOperationType());
|
||||
Collection<String> consumes = getConsumes(httpMethod, method);
|
||||
|
|
@ -61,7 +61,7 @@ class RequestPredicateFactory {
|
|||
return new WebOperationRequestPredicate(path, httpMethod, consumes, produces);
|
||||
}
|
||||
|
||||
private String getPath(String endpointId, String rootPath, Method method) {
|
||||
private String getPath(String rootPath, Method method) {
|
||||
return rootPath + Stream.of(method.getParameters()).filter(this::hasSelector)
|
||||
.map(this::slashName).collect(Collectors.joining());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS
|
|||
private <T> void registerGauge(MeterRegistry registry, T object, Iterable<Tag> tags,
|
||||
String name, String description, ToDoubleFunction<T> value) {
|
||||
Gauge.Builder<?> builder = Gauge.builder(name, object, value);
|
||||
builder.tags(this.tags).description(description).register(registry);
|
||||
builder.tags(tags).description(description).register(registry);
|
||||
}
|
||||
|
||||
private <T> void registerTimedGauge(MeterRegistry registry, T object,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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,7 +62,7 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
|||
Assert.notNull(dataSource, "DataSource must not be null");
|
||||
Assert.notNull(metadataProvider, "MetadataProvider must not be null");
|
||||
this.dataSource = dataSource;
|
||||
this.metadataProvider = new CachingDataSourcePoolMetadataProvider(dataSource,
|
||||
this.metadataProvider = new CachingDataSourcePoolMetadataProvider(
|
||||
metadataProvider);
|
||||
this.name = name;
|
||||
this.tags = tags;
|
||||
|
|
@ -97,7 +97,7 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
|||
|
||||
private final DataSourcePoolMetadataProvider metadataProvider;
|
||||
|
||||
CachingDataSourcePoolMetadataProvider(DataSource dataSource,
|
||||
CachingDataSourcePoolMetadataProvider(
|
||||
DataSourcePoolMetadataProvider metadataProvider) {
|
||||
this.metadataProvider = metadataProvider;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||
String factoryName = BeanFactory.FACTORY_BEAN_PREFIX + name;
|
||||
if (this.beanFactory.isFactoryBean(factoryName)) {
|
||||
Class<?> factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory,
|
||||
beanDefinition, name);
|
||||
beanDefinition);
|
||||
this.beanTypes.put(name, factoryBeanGeneric);
|
||||
this.beanTypes.put(factoryName,
|
||||
this.beanFactory.getType(factoryName));
|
||||
|
|
@ -216,13 +216,12 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||
* generics in its method signature.
|
||||
* @param beanFactory the source bean factory
|
||||
* @param definition the bean definition
|
||||
* @param name the name of the bean
|
||||
* @return the generic type of the {@link FactoryBean} or {@code null}
|
||||
*/
|
||||
private Class<?> getFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
||||
BeanDefinition definition, String name) {
|
||||
BeanDefinition definition) {
|
||||
try {
|
||||
return doGetFactoryBeanGeneric(beanFactory, definition, name);
|
||||
return doGetFactoryBeanGeneric(beanFactory, definition);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return null;
|
||||
|
|
@ -230,21 +229,21 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||
}
|
||||
|
||||
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
||||
BeanDefinition definition, String name)
|
||||
BeanDefinition definition)
|
||||
throws Exception, ClassNotFoundException, LinkageError {
|
||||
if (StringUtils.hasLength(definition.getFactoryBeanName())
|
||||
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
|
||||
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
|
||||
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition);
|
||||
}
|
||||
if (StringUtils.hasLength(definition.getBeanClassName())) {
|
||||
return getDirectFactoryBeanGeneric(beanFactory, definition, name);
|
||||
return getDirectFactoryBeanGeneric(beanFactory, definition);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Class<?> getConfigurationClassFactoryBeanGeneric(
|
||||
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
|
||||
String name) throws Exception {
|
||||
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
|
||||
throws Exception {
|
||||
Method method = getFactoryMethod(beanFactory, definition);
|
||||
Class<?> generic = ResolvableType.forMethodReturnType(method)
|
||||
.as(FactoryBean.class).resolveGeneric();
|
||||
|
|
@ -305,8 +304,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|||
}
|
||||
|
||||
private Class<?> getDirectFactoryBeanGeneric(
|
||||
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
|
||||
String name) throws ClassNotFoundException, LinkageError {
|
||||
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
|
||||
throws ClassNotFoundException, LinkageError {
|
||||
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
|
||||
beanFactory.getBeanClassLoader());
|
||||
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
|
|||
|
|
@ -106,8 +106,7 @@ public class SessionAutoConfiguration {
|
|||
*/
|
||||
abstract static class SessionConfigurationImportSelector implements ImportSelector {
|
||||
|
||||
protected final String[] selectImports(AnnotationMetadata importingClassMetadata,
|
||||
WebApplicationType webApplicationType) {
|
||||
protected final String[] selectImports(WebApplicationType webApplicationType) {
|
||||
List<String> imports = new ArrayList<>();
|
||||
StoreType[] types = StoreType.values();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
|
|
@ -128,8 +127,7 @@ public class SessionAutoConfiguration {
|
|||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return super.selectImports(importingClassMetadata,
|
||||
WebApplicationType.REACTIVE);
|
||||
return super.selectImports(WebApplicationType.REACTIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -143,8 +141,7 @@ public class SessionAutoConfiguration {
|
|||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return super.selectImports(importingClassMetadata,
|
||||
WebApplicationType.SERVLET);
|
||||
return super.selectImports(WebApplicationType.SERVLET);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ final class SessionStoreMappings {
|
|||
.entrySet()) {
|
||||
for (Map.Entry<WebApplicationType, Class<?>> entry : storeEntry.getValue()
|
||||
.entrySet()) {
|
||||
if (entry.getValue().getName().equals(configurationClassName)) {
|
||||
if (entry.getKey() == webApplicationType
|
||||
&& entry.getValue().getName().equals(configurationClassName)) {
|
||||
return storeEntry.getKey();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
|
|||
Set<URL> urls = new HashSet<>();
|
||||
findGroovyJarsDirectly(parent, urls);
|
||||
if (urls.isEmpty()) {
|
||||
findGroovyJarsFromClassPath(parent, urls);
|
||||
findGroovyJarsFromClassPath(urls);
|
||||
}
|
||||
Assert.state(!urls.isEmpty(), "Unable to find groovy JAR");
|
||||
return new ArrayList<>(urls).toArray(new URL[urls.size()]);
|
||||
|
|
@ -202,7 +202,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private void findGroovyJarsFromClassPath(ClassLoader parent, Set<URL> urls) {
|
||||
private void findGroovyJarsFromClassPath(Set<URL> urls) {
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
String[] entries = classpath.split(System.getProperty("path.separator"));
|
||||
for (String entry : entries) {
|
||||
|
|
|
|||
|
|
@ -280,8 +280,7 @@ public class GroovyCompiler {
|
|||
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
|
||||
throws CompilationFailedException {
|
||||
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context,
|
||||
classNode);
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source);
|
||||
ClassNode mainClassNode = MainClass.get(source.getAST().getClasses());
|
||||
|
||||
// Additional auto configuration
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -17,8 +17,6 @@
|
|||
package org.springframework.boot.cli.compiler;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassHelper;
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.classgen.GeneratorContext;
|
||||
import org.codehaus.groovy.control.SourceUnit;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
|
||||
|
|
@ -33,8 +31,7 @@ class SmartImportCustomizer extends ImportCustomizer {
|
|||
|
||||
private SourceUnit source;
|
||||
|
||||
SmartImportCustomizer(SourceUnit source, GeneratorContext context,
|
||||
ClassNode classNode) {
|
||||
SmartImportCustomizer(SourceUnit source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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,11 +80,10 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
|
|||
public void applyToMainClass(GroovyClassLoader loader,
|
||||
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
||||
SourceUnit source, ClassNode classNode) throws CompilationFailedException {
|
||||
addEnableAutoConfigurationAnnotation(source, classNode);
|
||||
addEnableAutoConfigurationAnnotation(classNode);
|
||||
}
|
||||
|
||||
private void addEnableAutoConfigurationAnnotation(SourceUnit source,
|
||||
ClassNode classNode) {
|
||||
private void addEnableAutoConfigurationAnnotation(ClassNode classNode) {
|
||||
if (!hasEnableAutoConfigureAnnotation(classNode)) {
|
||||
AnnotationNode annotationNode = new AnnotationNode(
|
||||
ClassHelper.make("EnableAutoConfiguration"));
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class Connection {
|
|||
public void run() throws Exception {
|
||||
if (this.header.contains("Upgrade: websocket")
|
||||
&& this.header.contains("Sec-WebSocket-Version: 13")) {
|
||||
runWebSocket(this.header);
|
||||
runWebSocket();
|
||||
}
|
||||
if (this.header.contains("GET /livereload.js")) {
|
||||
this.outputStream.writeHttp(getClass().getResourceAsStream("livereload.js"),
|
||||
|
|
@ -88,7 +88,7 @@ class Connection {
|
|||
}
|
||||
}
|
||||
|
||||
private void runWebSocket(String header) throws Exception {
|
||||
private void runWebSocket() throws Exception {
|
||||
String accept = getWebsocketAcceptResponse();
|
||||
this.outputStream.writeHeaders("HTTP/1.1 101 Switching Protocols",
|
||||
"Upgrade: websocket", "Connection: Upgrade",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -178,15 +178,20 @@ public class JsonTestersAutoConfiguration {
|
|||
}
|
||||
|
||||
private void processField(Object bean, Field field) {
|
||||
if (AbstractJsonMarshalTester.class.isAssignableFrom(field.getType())
|
||||
|| BasicJsonTester.class.isAssignableFrom(field.getType())) {
|
||||
ResolvableType type = ResolvableType.forField(field).getGeneric();
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
Object tester = ReflectionUtils.getField(field, bean);
|
||||
if (tester != null) {
|
||||
ReflectionTestUtils.invokeMethod(tester, "initialize",
|
||||
bean.getClass(), type);
|
||||
}
|
||||
if (AbstractJsonMarshalTester.class.isAssignableFrom(field.getType())) {
|
||||
initializeTester(bean, field, bean.getClass(),
|
||||
ResolvableType.forField(field).getGeneric());
|
||||
}
|
||||
else if (BasicJsonTester.class.isAssignableFrom(field.getType())) {
|
||||
initializeTester(bean, field, bean.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeTester(Object bean, Field field, Object... args) {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
Object tester = ReflectionUtils.getField(field, bean);
|
||||
if (tester != null) {
|
||||
ReflectionTestUtils.invokeMethod(tester, "initialize", args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -20,7 +20,6 @@ import java.io.File;
|
|||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
|
@ -80,10 +79,9 @@ public class BasicJsonTester {
|
|||
* UTF-8.
|
||||
* @param resourceLoadClass the source class used when loading relative classpath
|
||||
* resources
|
||||
* @param type the type under test
|
||||
*/
|
||||
protected final void initialize(Class<?> resourceLoadClass, ResolvableType type) {
|
||||
this.initialize(resourceLoadClass, null, type);
|
||||
protected final void initialize(Class<?> resourceLoadClass) {
|
||||
this.initialize(resourceLoadClass, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,11 +89,9 @@ public class BasicJsonTester {
|
|||
* @param resourceLoadClass the source class used when loading relative classpath
|
||||
* resources
|
||||
* @param charset the charset used when loading relative classpath resources
|
||||
* @param type the type under test
|
||||
* @since 1.4.1
|
||||
*/
|
||||
protected final void initialize(Class<?> resourceLoadClass, Charset charset,
|
||||
ResolvableType type) {
|
||||
protected final void initialize(Class<?> resourceLoadClass, Charset charset) {
|
||||
if (this.loader == null) {
|
||||
this.loader = new JsonLoader(resourceLoadClass, charset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -97,7 +97,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
|
||||
private Map<Definition, String> beanNameRegistry = new HashMap<>();
|
||||
|
||||
private Map<Field, RegisteredField> fieldRegistry = new HashMap<>();
|
||||
private Map<Field, String> fieldRegistry = new HashMap<>();
|
||||
|
||||
private Map<String, SpyDefinition> spies = new HashMap<>();
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
this.mockitoBeans.add(mock);
|
||||
this.beanNameRegistry.put(definition, beanName);
|
||||
if (field != null) {
|
||||
this.fieldRegistry.put(field, new RegisteredField(definition, beanName));
|
||||
this.fieldRegistry.put(field, beanName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
this.spies.put(beanName, definition);
|
||||
this.beanNameRegistry.put(definition, beanName);
|
||||
if (field != null) {
|
||||
this.fieldRegistry.put(field, new RegisteredField(definition, beanName));
|
||||
this.fieldRegistry.put(field, beanName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -370,9 +370,9 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
}
|
||||
|
||||
private void postProcessField(Object bean, Field field) {
|
||||
RegisteredField registered = this.fieldRegistry.get(field);
|
||||
if (registered != null && StringUtils.hasLength(registered.getBeanName())) {
|
||||
inject(field, bean, registered.getBeanName(), registered.getDefinition());
|
||||
String beanName = this.fieldRegistry.get(field);
|
||||
if (StringUtils.hasText(beanName)) {
|
||||
inject(field, bean, beanName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -380,11 +380,10 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
String beanName = this.beanNameRegistry.get(definition);
|
||||
Assert.state(StringUtils.hasLength(beanName),
|
||||
() -> "No bean found for definition " + definition);
|
||||
inject(field, target, beanName, definition);
|
||||
inject(field, target, beanName);
|
||||
}
|
||||
|
||||
private void inject(Field field, Object target, String beanName,
|
||||
Definition definition) {
|
||||
private void inject(Field field, Object target, String beanName) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
Assert.state(ReflectionUtils.getField(field, target) == null,
|
||||
|
|
@ -512,28 +511,4 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* A registered field item.
|
||||
*/
|
||||
private static class RegisteredField {
|
||||
|
||||
private final Definition definition;
|
||||
|
||||
private final String beanName;
|
||||
|
||||
RegisteredField(Definition definition, String beanName) {
|
||||
this.definition = definition;
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public Definition getDefinition() {
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,11 @@ class TestRestTemplateTestContextCustomizer implements ContextCustomizer {
|
|||
private void registerTestRestTemplate(ConfigurableApplicationContext context) {
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
registerTestRestTemplate(context, (BeanDefinitionRegistry) context);
|
||||
registerTestRestTemplate((BeanDefinitionRegistry) context);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerTestRestTemplate(ConfigurableApplicationContext context,
|
||||
BeanDefinitionRegistry registry) {
|
||||
private void registerTestRestTemplate(BeanDefinitionRegistry registry) {
|
||||
RootBeanDefinition definition = new RootBeanDefinition(
|
||||
TestRestTemplateRegistrar.class);
|
||||
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
|
|
|||
|
|
@ -65,12 +65,11 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
|||
private void registerWebTestClient(ConfigurableApplicationContext context) {
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
registerWebTestClient(context, (BeanDefinitionRegistry) context);
|
||||
registerWebTestClient((BeanDefinitionRegistry) context);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerWebTestClient(ConfigurableApplicationContext context,
|
||||
BeanDefinitionRegistry registry) {
|
||||
private void registerWebTestClient(BeanDefinitionRegistry registry) {
|
||||
RootBeanDefinition definition = new RootBeanDefinition(
|
||||
WebTestClientRegistrar.class);
|
||||
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -99,12 +99,11 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
|||
public void visitFileHeader(CentralDirectoryFileHeader fileHeader, int dataOffset) {
|
||||
AsciiBytes name = applyFilter(fileHeader.getName());
|
||||
if (name != null) {
|
||||
add(name, fileHeader, dataOffset);
|
||||
add(name, dataOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(AsciiBytes name, CentralDirectoryFileHeader fileHeader,
|
||||
int dataOffset) {
|
||||
private void add(AsciiBytes name, int dataOffset) {
|
||||
this.hashCodes[this.size] = name.hashCode();
|
||||
this.centralDirectoryOffsets[this.size] = dataOffset;
|
||||
this.positions[this.size] = this.size;
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ public class ConfigFileApplicationListener
|
|||
String loadProfile) {
|
||||
try {
|
||||
Resource resource = this.resourceLoader.getResource(location);
|
||||
String description = getDescription(profile, location, resource);
|
||||
String description = getDescription(location, resource);
|
||||
if (profile != null) {
|
||||
description = description + " for profile " + profile;
|
||||
}
|
||||
|
|
@ -482,8 +482,7 @@ public class ConfigFileApplicationListener
|
|||
}
|
||||
}
|
||||
|
||||
private String getDescription(Profile profile, String location,
|
||||
Resource resource) {
|
||||
private String getDescription(String location, Resource resource) {
|
||||
try {
|
||||
if (resource != null) {
|
||||
String uri = resource.getURI().toASCIIString();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -41,8 +41,7 @@ class ArrayBinder extends IndexedElementsBinder<Object> {
|
|||
IndexedCollectionSupplier collection = new IndexedCollectionSupplier(
|
||||
ArrayList::new);
|
||||
ResolvableType elementType = target.getType().getComponentType();
|
||||
bindIndexed(name, target, elementBinder, collection, target.getType(),
|
||||
elementType);
|
||||
bindIndexed(name, elementBinder, collection, target.getType(), elementType);
|
||||
if (collection.wasSupplied()) {
|
||||
List<Object> list = (List<Object>) collection.get();
|
||||
Object array = Array.newInstance(elementType.resolve(), list.size());
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public class Binder {
|
|||
}
|
||||
if (property != null) {
|
||||
try {
|
||||
return bindProperty(name, target, handler, context, property);
|
||||
return bindProperty(target, context, property);
|
||||
}
|
||||
catch (ConverterNotFoundException ex) {
|
||||
// We might still be able to bind it as a bean
|
||||
|
|
@ -295,8 +295,8 @@ public class Binder {
|
|||
.filter(Objects::nonNull).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
private <T> Object bindProperty(ConfigurationPropertyName name, Bindable<T> target,
|
||||
BindHandler handler, Context context, ConfigurationProperty property) {
|
||||
private <T> Object bindProperty(Bindable<T> target, Context context,
|
||||
ConfigurationProperty property) {
|
||||
context.setConfigurationProperty(property);
|
||||
Object result = property.getValue();
|
||||
result = this.placeholdersResolver.resolvePlaceholders(result);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -45,7 +45,7 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
|
|||
ResolvableType elementType = target.getType().asCollection().getGeneric();
|
||||
ResolvableType aggregateType = ResolvableType.forClassWithGenerics(List.class,
|
||||
target.getType().asCollection().getGenerics());
|
||||
bindIndexed(name, target, elementBinder, collection, aggregateType, elementType);
|
||||
bindIndexed(name, elementBinder, collection, aggregateType, elementType);
|
||||
if (collection.wasSupplied()) {
|
||||
return collection.get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -53,7 +53,7 @@ abstract class IndexedElementsBinder<T> extends AggregateBinder<T> {
|
|||
return source == null || source instanceof IterableConfigurationPropertySource;
|
||||
}
|
||||
|
||||
protected final void bindIndexed(ConfigurationPropertyName name, Bindable<?> target,
|
||||
protected final void bindIndexed(ConfigurationPropertyName name,
|
||||
AggregateElementBinder elementBinder, IndexedCollectionSupplier collection,
|
||||
ResolvableType aggregateType, ResolvableType elementType) {
|
||||
for (ConfigurationPropertySource source : getContext().getSources()) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -49,11 +49,10 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope
|
|||
SpringIterableConfigurationPropertySource(EnumerablePropertySource<?> propertySource,
|
||||
PropertyMapper mapper) {
|
||||
super(propertySource, mapper, null);
|
||||
assertEnumerablePropertySource(propertySource);
|
||||
assertEnumerablePropertySource();
|
||||
}
|
||||
|
||||
private void assertEnumerablePropertySource(
|
||||
EnumerablePropertySource<?> propertySource) {
|
||||
private void assertEnumerablePropertySource() {
|
||||
if (getPropertySource() instanceof MapPropertySource) {
|
||||
try {
|
||||
((MapPropertySource) getPropertySource()).getSource().size();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -48,10 +48,10 @@ class TomcatErrorPage {
|
|||
this.location = errorPage.getPath();
|
||||
this.exceptionType = errorPage.getExceptionName();
|
||||
this.errorCode = errorPage.getStatusCode();
|
||||
this.nativePage = createNativePage(errorPage);
|
||||
this.nativePage = createNativePage();
|
||||
}
|
||||
|
||||
private Object createNativePage(ErrorPage errorPage) {
|
||||
private Object createNativePage() {
|
||||
try {
|
||||
if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) {
|
||||
return BeanUtils
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public class TomcatWebServer implements WebServer {
|
|||
addPreviouslyRemovedConnectors();
|
||||
Connector connector = this.tomcat.getConnector();
|
||||
if (connector != null && this.autoStart) {
|
||||
startConnector(connector);
|
||||
startConnector();
|
||||
}
|
||||
checkThatConnectorsHaveStarted();
|
||||
this.started = true;
|
||||
|
|
@ -264,7 +264,7 @@ public class TomcatWebServer implements WebServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void startConnector(Connector connector) {
|
||||
private void startConnector() {
|
||||
try {
|
||||
for (Container child : this.tomcat.getHost().findChildren()) {
|
||||
if (child instanceof TomcatEmbeddedContext) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -72,8 +72,7 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
|
|||
SSLContext sslContext = SSLContext.getInstance(this.ssl.getProtocol());
|
||||
sslContext.init(getKeyManagers(this.ssl, this.sslStoreProvider),
|
||||
getTrustManagers(this.ssl, this.sslStoreProvider), null);
|
||||
builder.addHttpsListener(this.port, getListenAddress(this.address),
|
||||
sslContext);
|
||||
builder.addHttpsListener(this.port, getListenAddress(), sslContext);
|
||||
builder.setSocketOption(Options.SSL_CLIENT_AUTH_MODE,
|
||||
getSslClientAuthMode(this.ssl));
|
||||
if (this.ssl.getEnabledProtocols() != null) {
|
||||
|
|
@ -93,7 +92,7 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
|
|||
}
|
||||
}
|
||||
|
||||
private String getListenAddress(InetAddress address) {
|
||||
private String getListenAddress() {
|
||||
if (this.address == null) {
|
||||
return "0.0.0.0";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -48,8 +48,7 @@ abstract class ServletComponentHandler {
|
|||
return this.typeFilter;
|
||||
}
|
||||
|
||||
protected String[] extractUrlPatterns(String attribute,
|
||||
Map<String, Object> attributes) {
|
||||
protected String[] extractUrlPatterns(Map<String, Object> attributes) {
|
||||
String[] value = (String[]) attributes.get("value");
|
||||
String[] urlPatterns = (String[]) attributes.get("urlPatterns");
|
||||
if (urlPatterns.length > 0) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -53,8 +53,7 @@ class WebFilterHandler extends ServletComponentHandler {
|
|||
String name = determineName(attributes, beanDefinition);
|
||||
builder.addPropertyValue("name", name);
|
||||
builder.addPropertyValue("servletNames", attributes.get("servletNames"));
|
||||
builder.addPropertyValue("urlPatterns",
|
||||
extractUrlPatterns("urlPatterns", attributes));
|
||||
builder.addPropertyValue("urlPatterns", extractUrlPatterns(attributes));
|
||||
registry.registerBeanDefinition(name, builder.getBeanDefinition());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 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.
|
||||
|
|
@ -51,8 +51,7 @@ class WebServletHandler extends ServletComponentHandler {
|
|||
String name = determineName(attributes, beanDefinition);
|
||||
builder.addPropertyValue("name", name);
|
||||
builder.addPropertyValue("servlet", beanDefinition);
|
||||
builder.addPropertyValue("urlMappings",
|
||||
extractUrlPatterns("urlPatterns", attributes));
|
||||
builder.addPropertyValue("urlMappings", extractUrlPatterns(attributes));
|
||||
builder.addPropertyValue("multipartConfig",
|
||||
determineMultipartConfig(beanDefinition));
|
||||
registry.registerBeanDefinition(name, builder.getBeanDefinition());
|
||||
|
|
|
|||
Loading…
Reference in New Issue