You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
I've fixed this for Spring 2.5.2, introducing a dedicated "ScriptFactory.requiresScriptedObjectRefresh(ScriptSource)" method that takes into account whether a modified source has been found for a type check, indicating the need for a refresh until the next getScriptedObject call from the TargetSource.
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:
1 votes, 1 watchers
The text was updated successfully, but these errors were encountered: