@@ -112,12 +112,11 @@ public Class<?> enhance(Class<?> configClass, @Nullable ClassLoader classLoader)
112112
113113 try {
114114 // Use original ClassLoader if config class not locally loaded in overriding class loader
115- if (classLoader instanceof SmartClassLoader smartClassLoader &&
116- classLoader != configClass . getClassLoader () ) {
115+ boolean classLoaderMismatch = (classLoader != null && classLoader != configClass . getClassLoader ());
116+ if ( classLoaderMismatch && classLoader instanceof SmartClassLoader smartClassLoader ) {
117117 classLoader = smartClassLoader .getOriginalClassLoader ();
118118 }
119119 Enhancer enhancer = newEnhancer (configClass , classLoader );
120- boolean classLoaderMismatch = (classLoader != null && classLoader != configClass .getClassLoader ());
121120 Class <?> enhancedClass = createClass (enhancer , classLoaderMismatch );
122121 if (logger .isTraceEnabled ()) {
123122 logger .trace (String .format ("Successfully enhanced %s; enhanced class name is: %s" ,
@@ -188,8 +187,7 @@ private Class<?> createClass(Enhancer enhancer, boolean fallback) {
188187 /**
189188 * Marker interface to be implemented by all @Configuration CGLIB subclasses.
190189 * Facilitates idempotent behavior for {@link ConfigurationClassEnhancer#enhance}
191- * through checking to see if candidate classes are already assignable to it, for example,
192- * have already been enhanced.
190+ * through checking to see if candidate classes are already assignable to it.
193191 * <p>Also extends {@link BeanFactoryAware}, as all enhanced {@code @Configuration}
194192 * classes require access to the {@link BeanFactory} that created them.
195193 * <p>Note that this interface is intended for framework-internal use only, however
0 commit comments