Description
Roman Urosov opened SPR-4356 and commented
When AbstractApplicationContext.getBeansOfType() is called, all instances of ResourceScriptSource updates their lastModified property (if script file is updated), but bean itself remains unrefreshed.
Therefore, when user calls refreshable bean, the corresponding check (requiresRefresh()) returns false and user gets an old instance of bean.
Here are some stack traces:
First, calling AbstractApplicationContext.getBeansOfType() for arbitrary bean type.
main@1, priority=5, in group 'main', status: 'RUNNING'
getScriptAsString():91, ResourceScriptSource.java <-- lastModified is updated, but bean is not reloaded
getScriptedObjectType():191, GroovyScriptFactory.java
predictBeanType():240, ScriptFactoryPostProcessor.java
predictBeanType():488, AbstractAutowireCapableBeanFactory.java
getBeanNamesForType():212, DefaultListableBeanFactory.java
getBeansOfType():294, DefaultListableBeanFactory.java
getBeansOfType():288, DefaultListableBeanFactory.java
getBeansOfType():949, AbstractApplicationContext.java <-- searching for beans of any type
Then, trying to call refreshable bean, but it does not refresh:
main@1, priority=5, in group 'main', status: 'RUNNING'
isModified():113, ResourceScriptSource.java <-- returns false
requiresRefresh():60, RefreshableScriptTargetSource.java
getTarget():81, AbstractRefreshableTargetSource.java
invoke():184, JdkDynamicAopProxy.java
getMetaClass():-1 <--- calling refreshable bean method
Affects: 2.5.1
Issue Links:
- Scripted beans not updated after a script compilation error in getScriptedObjectType [SPR-14007] #18579 Scripted beans not updated after a script compilation error in getScriptedObjectType
1 votes, 1 watchers