Polish “Remove or use unused method parameters”

Closes gh-11812
This commit is contained in:
Andy Wilkinson
2018-02-01 20:36:47 +00:00
parent 717bd2c580
commit 875091ed85
25 changed files with 76 additions and 106 deletions

View File

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

View File

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

View File

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

View File

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