Skip to content

Commit f5dd4d2

Browse files
committed
Polishing
1 parent 192113d commit f5dd4d2

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.HashSet;
3232
import java.util.LinkedHashSet;
3333
import java.util.List;
34-
import java.util.Map;
3534
import java.util.Set;
3635
import java.util.TreeSet;
3736
import java.util.concurrent.ConcurrentHashMap;
@@ -156,7 +155,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
156155
private final NamedThreadLocal<String> currentlyCreatedBean = new NamedThreadLocal<>("Currently created bean");
157156

158157
/** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */
159-
private final Map<String, BeanWrapper> factoryBeanInstanceCache = new ConcurrentHashMap<>(16);
158+
private final ConcurrentMap<String, BeanWrapper> factoryBeanInstanceCache = new ConcurrentHashMap<>(16);
160159

161160
/** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
162161
private final ConcurrentMap<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache =

spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@
4747

4848
/**
4949
* Unit tests for {@link org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor}
50-
* processing the JSR-303 {@link javax.inject.Inject} annotation.
50+
* processing the JSR-330 {@link javax.inject.Inject} annotation.
5151
*
5252
* @author Juergen Hoeller
5353
* @since 3.0
@@ -550,11 +550,9 @@ public void testObjectFactoryWithTypedMapMethod() throws Exception {
550550
}
551551

552552
/**
553-
* Verifies that a dependency on a {@link org.springframework.beans.factory.FactoryBean} can be autowired via
554-
* {@link org.springframework.beans.factory.annotation.Autowired @Inject}, specifically addressing the JIRA issue
555-
* raised in <a
556-
* href="http://opensource.atlassian.com/projects/spring/browse/SPR-4040"
557-
* target="_blank">SPR-4040</a>.
553+
* Verifies that a dependency on a {@link org.springframework.beans.factory.FactoryBean}
554+
* can be autowired via {@link org.springframework.beans.factory.annotation.Autowired @Inject},
555+
* specifically addressing SPR-4040.
558556
*/
559557
@Test
560558
public void testBeanAutowiredWithFactoryBean() {
@@ -1315,7 +1313,7 @@ public final FactoryBean<?> getFactoryBean() {
13151313
public static class StringFactoryBean implements FactoryBean<String> {
13161314

13171315
@Override
1318-
public String getObject() throws Exception {
1316+
public String getObject() {
13191317
return "";
13201318
}
13211319

spring-core/src/main/java/org/springframework/core/ResolvableType.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ public ResolvableType as(Class<?> type) {
430430
if (this == NONE) {
431431
return NONE;
432432
}
433-
if (ObjectUtils.nullSafeEquals(resolve(), type)) {
433+
Class<?> resolved = resolve();
434+
if (resolved == null || resolved == type) {
434435
return this;
435436
}
436437
for (ResolvableType interfaceType : getInterfaces()) {
@@ -468,7 +469,7 @@ public ResolvableType getSuperType() {
468469
*/
469470
public ResolvableType[] getInterfaces() {
470471
Class<?> resolved = resolve();
471-
if (resolved == null || ObjectUtils.isEmpty(resolved.getGenericInterfaces())) {
472+
if (resolved == null || resolved.getGenericInterfaces().length == 0) {
472473
return EMPTY_TYPES_ARRAY;
473474
}
474475
ResolvableType[] interfaces = this.interfaces;
@@ -818,7 +819,7 @@ ResolvableType resolveType() {
818819

819820
@Nullable
820821
private Type resolveBounds(Type[] bounds) {
821-
if (ObjectUtils.isEmpty(bounds) || Object.class == bounds[0]) {
822+
if (bounds.length == 0 || bounds[0] == Object.class) {
822823
return null;
823824
}
824825
return bounds[0];
@@ -1638,6 +1639,9 @@ enum Kind {UPPER, LOWER}
16381639
}
16391640

16401641

1642+
/**
1643+
* Internal {@link Type} used to represent an empty value.
1644+
*/
16411645
@SuppressWarnings("serial")
16421646
static class EmptyType implements Type, Serializable {
16431647

0 commit comments

Comments
 (0)