Polishing

This commit is contained in:
Juergen Hoeller 2017-09-10 21:56:31 +02:00
parent 30d67f7c42
commit 4371350b5d
4 changed files with 6 additions and 17 deletions

View File

@ -126,7 +126,8 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
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
String getScope();

View File

@ -368,18 +368,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
// 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)) {
try {
T convertedBean = getTypeConverter().convertIfNecessary(bean, requiredType);
@ -396,8 +384,6 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
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;
}

View File

@ -71,7 +71,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
* {@code @Profile} can therefore not be used to select an overloaded method with a
* particular argument signature over another; resolution between all factory methods
* 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>;
* see {@code ProfileDatabaseConfig} in {@link Configuration @Configuration}'s javadoc.
*

View File

@ -295,7 +295,9 @@ public class WebDataBinder extends DataBinder {
}
}
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.
return null;