Refresh cached value after unexpected mismatch (e.g. null vs non-null)
In addition to the previously addressed removal of bean definitions, this is able to deal with prototype factory methods returning non-null after null or also null after non-null. Stale cached values are getting refreshed rather than bypassed.
Closes gh-30794
@ -638,7 +638,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -638,7 +638,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -683,10 +683,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -683,10 +683,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
// Unexpected removal of target bean for cached argument -> re-resolve
catch(BeansExceptionex){
// Unexpected target bean mismatch for cached argument -> re-resolve
this.cached=false;
logger.debug("Failed to resolve cached argument",ex);
value=resolveFieldValue(field,bean,beanName);
}
}
@ -715,9 +717,8 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -715,9 +717,8 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -727,9 +728,13 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -727,9 +728,13 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
desc,autowiredBeanName,field.getType());
}
}
this.cachedFieldValue=cachedFieldValue;
this.cached=true;
}
else{
this.cachedFieldValue=null;
// cached flag remains false
}
this.cachedFieldValue=cachedFieldValue;
this.cached=true;
}
}
returnvalue;
@ -760,10 +765,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -760,10 +765,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -782,14 +789,13 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -782,14 +789,13 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -822,7 +828,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -822,7 +828,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -837,11 +843,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@@ -837,11 +843,12 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
@ -151,6 +151,59 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@@ -151,6 +151,59 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@ -3881,6 +3934,20 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@@ -3881,6 +3934,20 @@ public class AutowiredAnnotationBeanPostProcessorTests {