codeconsole commented on code in PR #16496:
URL: https://github.com/apache/grails-core/pull/16496#discussion_r4175691804
##########
grails-test-examples/mongodb/springboot/src/test/groovy/example/SpringBootStartMongoExtension.groovy:
##########
@@ -44,6 +44,8 @@ class SpringBootStartMongoExtension implements
IGlobalExtension {
@Override
void visitSpec(SpecInfo spec) {
spec.addSharedInitializerInterceptor { invocation ->
+ // The spec's own shared fields first: this runs in place of their
initializers.
+ invocation.proceed()
Review Comment:
Good catch, fixed in a2b567290f: the datastore is written first, then
`proceed()`.
`setupSpec()` itself wasn't affected. `addSharedInitializerInterceptor`
wraps only the method that runs the `@Shared` field initializers, and Spock
calls `setupSpec()` after that method and the interceptor have finished. What
did see null was a `@Shared` initializer that uses the datastore.
`SharedDatastoreSpec` now covers both: a `@Shared BookService` initialized from
`datastore.getService(BookService)`, and `setupSpec()` doing the same. With the
old order the initializer fails with a `NullPointerException`; `setupSpec()`
passes either way.
--
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]