matrei commented on code in PR #15195:
URL: https://github.com/apache/grails-core/pull/15195#discussion_r2486100449
##########
grails-scaffolding/src/main/groovy/grails/plugin/scaffolding/GormService.groovy:
##########
@@ -34,28 +35,37 @@ import org.grails.datastore.gorm.GormEntityApi
@CompileStatic
class GormService<T extends GormEntity<T>> {
- GormAllOperations<T> resource
+ GormAllOperations<T> gormStaticApi
+ Class<T> resource
String resourceName
String resourceClassName
boolean readOnly
GormService(Class<T> resource, boolean readOnly) {
- this.resource = resource.getDeclaredConstructor().newInstance() as
GormAllOperations<T>
+ this.resource = resource
this.readOnly = readOnly
resourceClassName = resource.simpleName
resourceName = GrailsNameUtils.getPropertyName(resource)
}
+ protected GormAllOperations<T> getGormStaticApi() {
+ if (gormStaticApi == null) {
+ // Lazy initialization - happens on first access when GORM is ready
+ gormStaticApi = GormEnhancer.findStaticApi(resource) as
GormAllOperations<T>
+ }
+ return gormStaticApi
+ }
Review Comment:
Should this be thread-safe?
##########
grails-scaffolding/src/main/groovy/grails/plugin/scaffolding/GormService.groovy:
##########
@@ -34,28 +35,37 @@ import org.grails.datastore.gorm.GormEntityApi
@CompileStatic
class GormService<T extends GormEntity<T>> {
- GormAllOperations<T> resource
+ private GormAllOperations<T> gormStaticApi
Review Comment:
From what I can tell, there was no `gormStaticApi` property before this
change, so it should be `private` as it is lazily instantiated in the getter.
However, the `resource` property has changed type, which is breaking.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]