Skip to content

Commit 7ee08f0

Browse files
authored
Merge pull request #13917 from jdaugherty/7.0.x
#13690 - ensure the data binder is initialized lazily
2 parents d7ba97e + e102de2 commit 7ee08f0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.springframework.context.ApplicationContext;
1818
import org.springframework.context.MessageSource;
1919
import org.springframework.context.annotation.Bean;
20+
import org.springframework.context.annotation.Lazy;
2021
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
2122

2223
@AutoConfiguration
@@ -31,6 +32,12 @@ public DataBindingConfiguration(DataBindingConfigurationProperties configuration
3132
this.configurationProperties = configurationProperties;
3233
}
3334

35+
/*
36+
Must be lazy initialized because plugins ValueConverters & StructuredBindingEditors may be initialized by the Grails
37+
Bean DSL instead of an AutoConfiguration. For example, DataBindingConfigurationSpec defines beans as part of the test
38+
startup and without this being Lazy it, those beans will never be wired to the GrailsWebDataBinder bean.
39+
*/
40+
@Lazy
3441
@Bean("grailsWebDataBinder")
3542
protected GrailsWebDataBinder grailsWebDataBinder(
3643
GrailsApplication grailsApplication,

grails-plugin-databinding/src/test/groovy/org/grails/plugins/databinding/DataBindingConfigurationSpec.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class DataBindingConfigurationSpec extends Specification implements GrailsUnitTe
3030
grailsApplication.mainContext.containsBean("grailsWebDataBinder")
3131
}
3232

33-
@PendingFeature(reason = 'test != test2')
3433
void "test custom ValueConverter are ordered if defined with @Order"() {
3534

3635
when:
@@ -43,7 +42,6 @@ class DataBindingConfigurationSpec extends Specification implements GrailsUnitTe
4342

4443
}
4544

46-
@PendingFeature(reason = 'test != test2')
4745
void "test customize data binding for the types which have standard ValueConverters using @Order"() {
4846
when:
4947
Map source = ["name": "John Doe", "prop": "test", "dob": "12031990"]

0 commit comments

Comments
 (0)