Skip to content

Commit d54af02

Browse files
committed
Update DatastoreServiceMethodInvokingFactoryBean
Previously, the getObjectType method was returning NULL because the closure in AbstractDatastoreInitializer is not called earlier in the bean processing. So, in order to resolve the type the AbstractBeanFactory initialize the MethodInvokingFactoryBean which results in initializing objectDefinitionSource(AnnotaionFilterInvocationDefinition) early before creating servletContext. Fixes apache/grails-core#12057
1 parent 3c2c64a commit d54af02

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/DatastoreServiceMethodInvokingFactoryBean.groovy

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ import org.springframework.lang.Nullable
1717
@CompileStatic
1818
class DatastoreServiceMethodInvokingFactoryBean extends MethodInvokingFactoryBean {
1919

20+
private Class<?> serviceClass
21+
22+
DatastoreServiceMethodInvokingFactoryBean(Class<?> serviceClass) {
23+
this.serviceClass = serviceClass
24+
}
25+
2026
@Nullable
2127
private ConfigurableBeanFactory beanFactory
2228

2329
@Override
2430
Class<?> getObjectType() {
25-
if (arguments != null && arguments.size() == 1) {
26-
return arguments[0] as Class<?>
27-
}
28-
return super.getObjectType()
31+
return serviceClass
2932
}
3033

3134
@Override

grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/bootstrap/AbstractDatastoreInitializer.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ abstract class AbstractDatastoreInitializer implements ResourceLoaderAware{
292292
}
293293
loadDataServices(null)
294294
.each {serviceName, serviceClass->
295-
"$serviceName"(DatastoreServiceMethodInvokingFactoryBean) {
295+
"$serviceName"(DatastoreServiceMethodInvokingFactoryBean, serviceClass) {
296296
targetObject = ref("${type}Datastore")
297297
targetMethod = 'getService'
298298
arguments = [serviceClass]

0 commit comments

Comments
 (0)