diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java
index bb1740e3972d..0a1f0a7d6910 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.support;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.lang.Nullable;
@@ -99,4 +100,22 @@ default Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor
return null;
}
+ /**
+ * Return a clone of this resolver instance if necessary, retaining its local
+ * configuration and allowing for the cloned instance to get associated with
+ * a new bean factory, or this original instance if there is no such state.
+ *
The default implementation creates a separate instance via the default
+ * class constructor, assuming no specific configuration state to copy.
+ * Subclasses may override this with custom configuration state handling
+ * or with standard {@link Cloneable} support (as implemented by Spring's
+ * own configurable {@code AutowireCandidateResolver} variants), or simply
+ * return {@code this} (as in {@link SimpleAutowireCandidateResolver}).
+ * @since 5.2.7
+ * @see GenericTypeAwareAutowireCandidateResolver#cloneIfNecessary()
+ * @see DefaultListableBeanFactory#copyConfigurationFrom
+ */
+ default AutowireCandidateResolver cloneIfNecessary() {
+ return BeanUtils.instantiateClass(getClass());
+ }
+
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
index 3bffd264e2f2..c9bd992ded5e 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
@@ -46,7 +46,6 @@
import javax.inject.Provider;
-import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.factory.BeanCreationException;
@@ -157,7 +156,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
private Comparator