Polishing

This commit is contained in:
Juergen Hoeller
2018-07-24 15:17:33 +02:00
parent 484addb4f8
commit 2ae2249842
4 changed files with 37 additions and 32 deletions

View File

@@ -31,9 +31,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
@@ -146,7 +144,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
private final Set<Class<?>> ignoredDependencyInterfaces = new HashSet<Class<?>>();
/** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */
private final Map<String, BeanWrapper> factoryBeanInstanceCache =
private final ConcurrentMap<String, BeanWrapper> factoryBeanInstanceCache =
new ConcurrentHashMap<String, BeanWrapper>(16);
/** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
@@ -1422,7 +1420,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
*/
protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) {
List<PropertyDescriptor> pds =
new LinkedList<PropertyDescriptor>(Arrays.asList(bw.getPropertyDescriptors()));
new ArrayList<PropertyDescriptor>(Arrays.asList(bw.getPropertyDescriptors()));
for (Iterator<PropertyDescriptor> it = pds.iterator(); it.hasNext();) {
PropertyDescriptor pd = it.next();
if (isExcludedFromDependencyCheck(pd)) {

View File

@@ -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.
@@ -45,7 +45,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
@@ -548,11 +548,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 <a
* href="http://opensource.atlassian.com/projects/spring/browse/SPR-4040"
* target="_blank">SPR-4040</a>.
* 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() {
@@ -1259,7 +1257,7 @@ public class InjectAnnotationBeanPostProcessorTests {
public static class StringFactoryBean implements FactoryBean<String> {
@Override
public String getObject() throws Exception {
public String getObject() {
return "";
}
@@ -1291,8 +1289,8 @@ public class InjectAnnotationBeanPostProcessorTests {
private Optional<TestBean> testBean;
@Inject
public void setTestBean(Optional<TestBean> testBeanFactory) {
this.testBean = testBeanFactory;
public void setTestBean(Optional<TestBean> testBean) {
this.testBean = testBean;
}
public Optional<TestBean> getTestBean() {
@@ -1317,8 +1315,8 @@ public class InjectAnnotationBeanPostProcessorTests {
private Optional<List<TestBean>> testBean;
@Inject
public void setTestBean(Optional<List<TestBean>> testBeanFactory) {
this.testBean = testBeanFactory;
public void setTestBean(Optional<List<TestBean>> testBean) {
this.testBean = testBean;
}
public Optional<List<TestBean>> getTestBean() {
@@ -1343,8 +1341,8 @@ public class InjectAnnotationBeanPostProcessorTests {
private Provider<Optional<TestBean>> testBean;
@Inject
public void setTestBean(Provider<Optional<TestBean>> testBeanFactory) {
this.testBean = testBeanFactory;
public void setTestBean(Provider<Optional<TestBean>> testBean) {
this.testBean = testBean;
}
public Optional<TestBean> getTestBean() {