From f5dd4d2c02681f90aab5ebe754527a9683e4345f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 22 Jul 2018 19:33:40 +0200 Subject: [PATCH] Polishing --- .../AbstractAutowireCapableBeanFactory.java | 3 +-- .../InjectAnnotationBeanPostProcessorTests.java | 14 ++++++-------- .../org/springframework/core/ResolvableType.java | 10 +++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 83447da675..5f5b5cda23 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -31,7 +31,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; @@ -156,7 +155,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac private final NamedThreadLocal currentlyCreatedBean = new NamedThreadLocal<>("Currently created bean"); /** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */ - private final Map factoryBeanInstanceCache = new ConcurrentHashMap<>(16); + private final ConcurrentMap factoryBeanInstanceCache = new ConcurrentHashMap<>(16); /** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */ private final ConcurrentMap, PropertyDescriptor[]> filteredPropertyDescriptorsCache = diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index 9bcac1203c..cc56cccb54 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ import static org.junit.Assert.*; /** * Unit tests for {@link org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor} - * processing the JSR-303 {@link javax.inject.Inject} annotation. + * processing the JSR-330 {@link javax.inject.Inject} annotation. * * @author Juergen Hoeller * @since 3.0 @@ -550,11 +550,9 @@ public class InjectAnnotationBeanPostProcessorTests { } /** - * Verifies that a dependency on a {@link org.springframework.beans.factory.FactoryBean} can be autowired via - * {@link org.springframework.beans.factory.annotation.Autowired @Inject}, specifically addressing the JIRA issue - * raised in SPR-4040. + * Verifies that a dependency on a {@link org.springframework.beans.factory.FactoryBean} + * can be autowired via {@link org.springframework.beans.factory.annotation.Autowired @Inject}, + * specifically addressing SPR-4040. */ @Test public void testBeanAutowiredWithFactoryBean() { @@ -1315,7 +1313,7 @@ public class InjectAnnotationBeanPostProcessorTests { public static class StringFactoryBean implements FactoryBean { @Override - public String getObject() throws Exception { + public String getObject() { return ""; } diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index e6a1b12b4e..68caa7259d 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -430,7 +430,8 @@ public class ResolvableType implements Serializable { if (this == NONE) { return NONE; } - if (ObjectUtils.nullSafeEquals(resolve(), type)) { + Class resolved = resolve(); + if (resolved == null || resolved == type) { return this; } for (ResolvableType interfaceType : getInterfaces()) { @@ -468,7 +469,7 @@ public class ResolvableType implements Serializable { */ public ResolvableType[] getInterfaces() { Class resolved = resolve(); - if (resolved == null || ObjectUtils.isEmpty(resolved.getGenericInterfaces())) { + if (resolved == null || resolved.getGenericInterfaces().length == 0) { return EMPTY_TYPES_ARRAY; } ResolvableType[] interfaces = this.interfaces; @@ -818,7 +819,7 @@ public class ResolvableType implements Serializable { @Nullable private Type resolveBounds(Type[] bounds) { - if (ObjectUtils.isEmpty(bounds) || Object.class == bounds[0]) { + if (bounds.length == 0 || bounds[0] == Object.class) { return null; } return bounds[0]; @@ -1638,6 +1639,9 @@ public class ResolvableType implements Serializable { } + /** + * Internal {@link Type} used to represent an empty value. + */ @SuppressWarnings("serial") static class EmptyType implements Type, Serializable {