-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicitly set resolve strategy to OWNER_FIRST
in BeanBuilder.invokeBeanDefiningClosure
#269
Comments
@rainboyan I created and attached a demo with the issue. Thank you for your quick response |
@tseveend Thank you for the demo. I can confirm that the relevant code that causes the error is as follows: grace-framework/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java Lines 657 to 664 in e1e9233
According to the Closures Delegation strategy, the default Delegation strategy is
|
I wrote a Groovy script to reproduce the issue. I'm not sure if this is a bug from Groovy 3 or Groovy 4, but the result is different when this code is executed in the class Plugin {
Closure doWithSpring() { {->
Properties properties = loadProperties()
println properties
}
}
def loadProperties() {
Properties properties = new Properties()
properties['foo'] = 'Foo'
properties
}
}
class BeanBuilder {
BeanBuilder beans(Closure<?> callable) {
callable.setDelegate(this)
// Groovy 4 should set it explicitly
callable.setResolveStrategy(Closure.OWNER_FIRST)
callable.call()
return this
}
@Override
public Object invokeMethod(String name, Object arg) {
println "BeanBuilder.invokeMethod($name, $arg)"
return this
}
}
BeanBuilder bb = new BeanBuilder()
Plugin plugin = new Plugin()
Closure c = plugin.doWithSpring()
c.setDelegate(bb)
c.setResolveStrategy(Closure.DELEGATE_FIRST)
bb.beans(c) |
OWNER_FIRST
in BeanBuilder.invokeBeanDefiningClosure
I reopened this issue because some tests fail, I recommend using Spring |
Grails plugin an error occur when doWithSpring is executed.
grace-framework/grails-plugin-api/src/main/groovy/org/grails/plugins/DefaultGrailsPlugin.java
Line 578 in e1e9233
The text was updated successfully, but these errors were encountered: