Polish “Remove or use unused method parameters”

Closes gh-11812
pull/11885/head
Andy Wilkinson 7 years ago
parent 717bd2c580
commit 875091ed85

@ -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.

@ -77,8 +77,7 @@ public class MappingsEndpointAutoConfiguration {
static class SpringMvcConfiguration {
@Bean
DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider(
ApplicationContext applicationContext) {
DispatcherServletsMappingDescriptionProvider dispatcherServletMappingDescriptionProvider() {
return new DispatcherServletsMappingDescriptionProvider();
}

@ -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());
}

@ -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,11 +229,11 @@ 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);
@ -243,8 +242,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
}
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) 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.
@ -49,7 +49,8 @@ abstract class AbstractSessionCondition extends SpringBootCondition {
ConditionMessage.Builder message = ConditionMessage
.forCondition("Session Condition");
Environment environment = context.getEnvironment();
StoreType required = SessionStoreMappings.getType(((AnnotationMetadata) metadata).getClassName());
StoreType required = SessionStoreMappings.getType(this.webApplicationType,
((AnnotationMetadata) metadata).getClassName());
if (!environment.containsProperty("spring.session.store-type")) {
return ConditionOutcome.match(message.didNotFind("property", "properties")
.items(ConditionMessage.Style.QUOTE, "spring.session.store-type"));

@ -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);
}
}

@ -80,12 +80,14 @@ final class SessionStoreMappings {
return configurationClass.getName();
}
static StoreType getType(String configurationClassName) {
static StoreType getType(WebApplicationType webApplicationType,
String configurationClassName) {
for (Map.Entry<StoreType, Map<WebApplicationType, Class<?>>> storeEntry : MAPPINGS
.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();
}
}

@ -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.

@ -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.

@ -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();
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",
bean.getClass(), type);
}
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());
String beanName = this.fieldRegistry.get(field);
if (StringUtils.hasText(beanName)) {
inject(field, bean, beanName);
}
}
@ -511,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);

@ -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.

@ -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());

@ -295,7 +295,8 @@ public class Binder {
.filter(Objects::nonNull).findFirst().orElse(null);
}
private <T> Object bindProperty(Bindable<T> target, 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.

@ -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.

@ -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(),
sslContext);
builder.addHttpsListener(this.port, getListenAddress(), sslContext);
builder.setSocketOption(Options.SSL_CLIENT_AUTH_MODE,
getSslClientAuthMode(this.ssl));
if (this.ssl.getEnabledProtocols() != null) {

@ -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,9 @@ 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(attribute);
String[] urlPatterns = (String[]) attributes.get("urlPatterns");
if (urlPatterns.length > 0) {
Assert.state(value.length == 0,
"The urlPatterns and value attributes are mutually exclusive.");

@ -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…
Cancel
Save