Nullability refinements and related polishing
This commit is contained in:
@@ -888,7 +888,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
// No type found for shortcut FactoryBean instance:
|
||||
// fall back to full creation of the FactoryBean instance.
|
||||
return super.getTypeForFactoryBean(beanName, mbd, allowInit);
|
||||
return super.getTypeForFactoryBean(beanName, mbd, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1990,6 +1990,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link MethodCallback} used to find {@link FactoryBean} type information.
|
||||
*/
|
||||
@@ -1999,12 +2000,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
|
||||
private ResolvableType result = ResolvableType.NONE;
|
||||
|
||||
|
||||
FactoryBeanMethodTypeFinder(String factoryMethodName) {
|
||||
this.factoryMethodName = factoryMethodName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
if (isFactoryBeanMethod(method)) {
|
||||
@@ -2028,13 +2027,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
FactoryBean.class.isAssignableFrom(method.getReturnType());
|
||||
}
|
||||
|
||||
|
||||
ResolvableType getResult() {
|
||||
Class<?> resolved = this.result.resolve();
|
||||
boolean foundResult = resolved != null && resolved != Object.class;
|
||||
return (foundResult ? this.result : ResolvableType.NONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
if (FactoryBean.class.isAssignableFrom(predictedType)) {
|
||||
if (beanInstance == null && !isFactoryDereference) {
|
||||
beanType = getTypeForFactoryBean(beanName, mbd, allowFactoryBeanInit);
|
||||
predictedType = (beanType != null) ? beanType.resolve() : null;
|
||||
predictedType = beanType.resolve();
|
||||
if (predictedType == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1377,17 +1377,19 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
}
|
||||
|
||||
private void copyRelevantMergedBeanDefinitionCaches(RootBeanDefinition previous,
|
||||
RootBeanDefinition mbd) {
|
||||
private void copyRelevantMergedBeanDefinitionCaches(RootBeanDefinition previous, RootBeanDefinition mbd) {
|
||||
if (ObjectUtils.nullSafeEquals(mbd.getBeanClassName(), previous.getBeanClassName()) &&
|
||||
ObjectUtils.nullSafeEquals(mbd.getFactoryBeanName(), previous.getFactoryBeanName()) &&
|
||||
ObjectUtils.nullSafeEquals(mbd.getFactoryMethodName(), previous.getFactoryMethodName()) &&
|
||||
(mbd.targetType == null || mbd.targetType.equals(previous.targetType))) {
|
||||
mbd.targetType = previous.targetType;
|
||||
mbd.isFactoryBean = previous.isFactoryBean;
|
||||
mbd.resolvedTargetType = previous.resolvedTargetType;
|
||||
mbd.factoryMethodReturnType = previous.factoryMethodReturnType;
|
||||
mbd.factoryMethodToIntrospect = previous.factoryMethodToIntrospect;
|
||||
ObjectUtils.nullSafeEquals(mbd.getFactoryMethodName(), previous.getFactoryMethodName())) {
|
||||
ResolvableType targetType = mbd.targetType;
|
||||
ResolvableType previousTargetType = previous.targetType;
|
||||
if (targetType == null || targetType.equals(previousTargetType)) {
|
||||
mbd.targetType = previousTargetType;
|
||||
mbd.isFactoryBean = previous.isFactoryBean;
|
||||
mbd.resolvedTargetType = previous.resolvedTargetType;
|
||||
mbd.factoryMethodReturnType = previous.factoryMethodReturnType;
|
||||
mbd.factoryMethodToIntrospect = previous.factoryMethodToIntrospect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1625,9 +1627,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
* @see #getBean(String)
|
||||
*/
|
||||
protected ResolvableType getTypeForFactoryBean(String beanName,
|
||||
RootBeanDefinition mbd, boolean allowInit) {
|
||||
|
||||
protected ResolvableType getTypeForFactoryBean(String beanName, RootBeanDefinition mbd, boolean allowInit) {
|
||||
ResolvableType result = getTypeForFactoryBeanFromAttributes(mbd);
|
||||
if (result != ResolvableType.NONE) {
|
||||
return result;
|
||||
|
||||
@@ -583,8 +583,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return StringUtils.toStringArray(result);
|
||||
}
|
||||
|
||||
private boolean isSingleton(String beanName, RootBeanDefinition mbd, BeanDefinitionHolder dbd) {
|
||||
return (dbd != null) ? mbd.isSingleton() : isSingleton(beanName);
|
||||
private boolean isSingleton(String beanName, RootBeanDefinition mbd, @Nullable BeanDefinitionHolder dbd) {
|
||||
return (dbd != null ? mbd.isSingleton() : isSingleton(beanName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user