Skip to content

Commit 4371350

Browse files
committed
Polishing
1 parent 30d67f7 commit 4371350

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
126126
void setScope(@Nullable String scope);
127127

128128
/**
129-
* Return the name of the current target scope for this bean.
129+
* Return the name of the current target scope for this bean,
130+
* or {@code null} if not known yet.
130131
*/
131132
@Nullable
132133
String getScope();

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,6 @@ else if (mbd.isPrototype()) {
368368
}
369369

370370
// Check if required type matches the type of the actual bean instance.
371-
// Note that the following return declarations are technically violating the
372-
// non-null policy for the getBean methods: However, these will only result
373-
// in null under very specific circumstances: such as a user-declared factory
374-
// method returning null or a user-provided FactoryBean.getObject() returning
375-
// null, without any custom post-processing of such null values. We will pass
376-
// them on as null to corresponding injection points in that exceptional case
377-
// but do not expect user-level getBean callers to deal with such null values.
378-
// In the end, regular getBean callers should be able to assign the outcome
379-
// to non-null variables/arguments without being compromised by rather esoteric
380-
// corner cases, in particular in functional configuration and Kotlin scenarios.
381-
// A future Spring generation might eventually forbid null values completely
382-
// and throw IllegalStateExceptions instead of leniently passing them through.
383371
if (requiredType != null && !requiredType.isInstance(bean)) {
384372
try {
385373
T convertedBean = getTypeConverter().convertIfNecessary(bean, requiredType);
@@ -396,8 +384,6 @@ else if (mbd.isPrototype()) {
396384
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
397385
}
398386
}
399-
// For the nullability warning, see the elaboration in the comment above;
400-
// in short: This is never going to be null unless user-declared code enforces null.
401387
return (T) bean;
402388
}
403389

spring-context/src/main/java/org/springframework/context/annotation/Profile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
* {@code @Profile} can therefore not be used to select an overloaded method with a
7272
* particular argument signature over another; resolution between all factory methods
7373
* for the same bean follows Spring's constructor resolution algorithm at creation time.
74-
* <b>Use distinct Java method names pointing to the same {@link @Bean#name bean name}
74+
* <b>Use distinct Java method names pointing to the same {@link Bean#name bean name}
7575
* if you'd like to define alternative beans with different profile conditions</b>;
7676
* see {@code ProfileDatabaseConfig} in {@link Configuration @Configuration}'s javadoc.
7777
*

spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ else if (Map.class.isAssignableFrom(fieldType)) {
295295
}
296296
}
297297
catch (IllegalArgumentException ex) {
298-
logger.debug("Failed to create default value - falling back to null: " + ex.getMessage());
298+
if (logger.isDebugEnabled()) {
299+
logger.debug("Failed to create default value - falling back to null: " + ex.getMessage());
300+
}
299301
}
300302
// Default value: null.
301303
return null;

0 commit comments

Comments
 (0)