GenericGroovyApplicationContext propagates BeanDefinitionParsingException only when context file is named 'beans.groovy' [SPR-12435] #17040
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Grzegorz Ćwiak opened SPR-12435 and commented
GenericGroovyApplicationContext propagates BeanDefinitionParsingException only when context file is named 'beans.groovy'
Given:
incorrect groovy bean config:
beans = {
}
Here '=' sign in this place is a mistake.
When instantiating the context:
GenericGroovyApplicationContext context = new GenericGroovyApplicationContext("classpath:beans.groovy");
It behaves differently depending on file name of the corrupted groovy config:
when it is named in any other way than 'beans.groovy', e.g. 'myServiceContext.groovy', than no exception is thrown, the context starts up but without any beans created, context.getBeanDefinitionCount() returns 0.
when it is named 'beans.groovy' the following error is reported:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Error evaluating Groovy script: startup failed:
beans.groovy: 1: you tried to assign a value to the class 'beans'. Do you have a script with this name?
@ line 1, column 1.
beans = {
^
1 error
Offending resource: class path resource [beans.groovy]; nested exception is org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
beans.groovy: 1: you tried to assign a value to the class 'beans'. Do you have a script with this name?
@ line 1, column 1.
beans = {
^
1 error
Affects: 4.0.2
The text was updated successfully, but these errors were encountered: