This is a duplicate of #9034.
It does not work again because "ScriptFactory.requiresScriptedObjectRefresh(ScriptSource)" is not used in "GroovyScriptFactory#getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces)"
I think come clarification is needed because it's not exactly the duplicate.
The problem happens when groovy script is invalid (syntax error etc.). Then result of a call to the groovy bean is unpredictable, it can execute old version of the script or throw an exception depending on whether AbstractApplicationContext.getBeansOfType() was called or not.
Good point: We're resetting the scriptClass, scriptResultClass and cachedResult fields in GroovyScriptFactorty when we run into a CompilationFailedException now, both in getScriptedObject and getScriptedObjectType. Analogously in BshScriptFactory as well.