Polishing
This commit is contained in:
parent
30d67f7c42
commit
4371350b5d
|
|
@ -126,7 +126,8 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||||
void setScope(@Nullable String scope);
|
void setScope(@Nullable String scope);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the current target scope for this bean.
|
* Return the name of the current target scope for this bean,
|
||||||
|
* or {@code null} if not known yet.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
String getScope();
|
String getScope();
|
||||||
|
|
|
||||||
|
|
@ -368,18 +368,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if required type matches the type of the actual bean instance.
|
// Check if required type matches the type of the actual bean instance.
|
||||||
// Note that the following return declarations are technically violating the
|
|
||||||
// non-null policy for the getBean methods: However, these will only result
|
|
||||||
// in null under very specific circumstances: such as a user-declared factory
|
|
||||||
// method returning null or a user-provided FactoryBean.getObject() returning
|
|
||||||
// null, without any custom post-processing of such null values. We will pass
|
|
||||||
// them on as null to corresponding injection points in that exceptional case
|
|
||||||
// but do not expect user-level getBean callers to deal with such null values.
|
|
||||||
// In the end, regular getBean callers should be able to assign the outcome
|
|
||||||
// to non-null variables/arguments without being compromised by rather esoteric
|
|
||||||
// corner cases, in particular in functional configuration and Kotlin scenarios.
|
|
||||||
// A future Spring generation might eventually forbid null values completely
|
|
||||||
// and throw IllegalStateExceptions instead of leniently passing them through.
|
|
||||||
if (requiredType != null && !requiredType.isInstance(bean)) {
|
if (requiredType != null && !requiredType.isInstance(bean)) {
|
||||||
try {
|
try {
|
||||||
T convertedBean = getTypeConverter().convertIfNecessary(bean, requiredType);
|
T convertedBean = getTypeConverter().convertIfNecessary(bean, requiredType);
|
||||||
|
|
@ -396,8 +384,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||||
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
|
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// For the nullability warning, see the elaboration in the comment above;
|
|
||||||
// in short: This is never going to be null unless user-declared code enforces null.
|
|
||||||
return (T) bean;
|
return (T) bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
* {@code @Profile} can therefore not be used to select an overloaded method with a
|
* {@code @Profile} can therefore not be used to select an overloaded method with a
|
||||||
* particular argument signature over another; resolution between all factory methods
|
* particular argument signature over another; resolution between all factory methods
|
||||||
* for the same bean follows Spring's constructor resolution algorithm at creation time.
|
* for the same bean follows Spring's constructor resolution algorithm at creation time.
|
||||||
* <b>Use distinct Java method names pointing to the same {@link @Bean#name bean name}
|
* <b>Use distinct Java method names pointing to the same {@link Bean#name bean name}
|
||||||
* if you'd like to define alternative beans with different profile conditions</b>;
|
* if you'd like to define alternative beans with different profile conditions</b>;
|
||||||
* see {@code ProfileDatabaseConfig} in {@link Configuration @Configuration}'s javadoc.
|
* see {@code ProfileDatabaseConfig} in {@link Configuration @Configuration}'s javadoc.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,9 @@ public class WebDataBinder extends DataBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
logger.debug("Failed to create default value - falling back to null: " + ex.getMessage());
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Failed to create default value - falling back to null: " + ex.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Default value: null.
|
// Default value: null.
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue