Describe the bug
Upgrading Spock 2.4-M1-groovy-4.0 to any version between 2.4-M2-groovy-4.0 and to 2.4-M5-groovy-4.0
We use a Spock extension to run specs within a certain (thread-local) context.
The Spock specs or features are annotated with an annotation @WithTenantContext. The annotation is handled by the TenantContextExtension.
The test application contains an initializing bean, verifying that the tenant context is not set during Spock initialization.
In the example code below, the assert assert TenantContextHolder.currentTenant == null succeeds during all Spock versions up to 2.4-M1-groovy-4.0, but fails since 2.4-M2-groovy-4.0 and newer.
To Reproduce
Spec:
@SpringBootTest(classes = TestApplication)
class SpockTransactionalTenantContextSpecification extends Specification {
@WithTenantContext
void 'tenant test'() {
expect:
TenantContextHolder.currentTenant != null
}
}
Test application:
@SpringBootApplication
class TestApplication {
@Bean
InitializingBean testService() {
return {
assert TenantContextHolder.currentTenant == null
}
}
}
Annotation:
@Retention(AnnotationRetention.RUNTIME)
@Inherited
@ExtensionAnnotation(TenantContextExtension::class)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class WithTenantContext(
val customerCode: String = ...
)
Extension:
class TenantContextExtension : IAnnotationDrivenExtension<WithTenantContext> {
private val tenantContextProvider: TenantContextProvider = ...
override fun visitSpecAnnotation(annotation: WithTenantContext, spec: SpecInfo) {
val interceptor = IMethodInterceptor { invocation ->
tenantContextProvider.inTenantContext(...) {
invocation.proceed()
}
}
spec.allFeatures.forEach { feature ->
feature.addInterceptor(interceptor)
}
}
override fun visitFeatureAnnotation(annotation: WithTenantContext, feature: FeatureInfo) {
val interceptor = IMethodInterceptor { invocation ->
tenantContextProvider.inTenantContext(...) {
invocation.proceed()
}
}
feature.addInterceptor(interceptor)
}
}
The TenantContextProvider is implemented with code similar to
class TenantContextProvider {
fun <V> inTenantContext(tenant: ..., callable: Callable<V>): V {
val previousTenant = TenantContextHolder.getCurrentTenant()
return try {
TenantContextHolder.setCurrentTenant(tenant)
callable.call()
} finally {
TenantContextHolder.setCurrentTenant(previousTenant)
}
}
}
where TenantContextHolder is a thread-local storage of some context.
Expected behavior
The spec to succeed, no thread local context should be set during the setup of the spec (by the Spring extension).
Actual behavior
The assertion fails, because a thread-local context is set during spec initialization.
Java version
Java 11, or 17 or 21
Buildtool version
Gradle 8.5 until Gradle 8.13
What operating system are you using
Linux
Dependencies
Below is the dependency diagram for the 2.4-M2-groovy-4.0 version. Newer dependency versions (also of other unrelated dependencies) shows the same behaviour as described in this issue.
------------------------------------------------------------
Project XXXXXXXX
------------------------------------------------------------
testRuntimeClasspath - Runtime classpath of null/test.
+--- io.github.microutils:kotlin-logging-jvm -> 2.1.23
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0 -> 1.9.22
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22
| | +--- org.jetbrains:annotations:13.0
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.22 (c)
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0 -> 1.9.21 (c)
| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0 -> 1.9.21 (c)
| +--- org.slf4j:slf4j-api:1.7.32 -> 2.0.9
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0 -> 1.9.21
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.21 -> 1.9.22 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.21
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.21 -> 1.9.22 (*)
+--- org.spockframework:spock-core -> 2.4-M2-groovy-4.0
| +--- org.apache.groovy:groovy:4.0.18
| | \--- org.apache.groovy:groovy-bom:4.0.18
| | +--- org.apache.groovy:groovy:4.0.18 (c)
| | +--- org.apache.groovy:groovy-json:4.0.18 (c)
| | \--- org.apache.groovy:groovy-xml:4.0.18 (c)
| +--- io.leangen.geantyref:geantyref:1.3.15
| +--- org.junit:junit-bom:5.10.2
| | +--- org.junit.jupiter:junit-jupiter:5.10.2 (c)
| | +--- org.junit.platform:junit-platform-engine:1.10.2 (c)
| | +--- org.junit.platform:junit-platform-launcher:1.10.2 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.10.2 (c)
| | +--- org.junit.jupiter:junit-jupiter-params:5.10.2 (c)
| | +--- org.junit.jupiter:junit-jupiter-engine:5.10.2 (c)
| | \--- org.junit.platform:junit-platform-commons:1.10.2 (c)
| +--- org.junit.platform:junit-platform-engine -> 1.10.2
| | +--- org.opentest4j:opentest4j:1.3.0
| | +--- org.junit.platform:junit-platform-commons:1.10.2
| | | \--- org.apiguardian:apiguardian-api:1.1.2
| | \--- org.apiguardian:apiguardian-api:1.1.2
| \--- org.hamcrest:hamcrest:2.2
+--- org.spockframework:spock-spring -> 2.4-M2-groovy-4.0
| +--- org.apache.groovy:groovy:4.0.18 (*)
| \--- org.spockframework:spock-core:2.4-M2-groovy-4.0 (*)
+--- org.junit.jupiter:junit-jupiter -> 5.10.2
| +--- org.junit.jupiter:junit-jupiter-api:5.10.2
| | +--- org.opentest4j:opentest4j:1.3.0
| | +--- org.junit.platform:junit-platform-commons:1.10.2 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.2
| +--- org.junit.jupiter:junit-jupiter-params:5.10.2
| | +--- org.junit.jupiter:junit-jupiter-api:5.10.2 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.2
| \--- org.junit.jupiter:junit-jupiter-engine:5.10.2
| +--- org.junit.platform:junit-platform-engine:1.10.2 (*)
| +--- org.junit.jupiter:junit-jupiter-api:5.10.2 (*)
| \--- org.apiguardian:apiguardian-api:1.1.2
+--- org.apache.commons:commons-lang3 -> 3.13.0
+--- project XXXXXXXX
| +--- io.github.microutils:kotlin-logging-jvm -> 2.1.23 (*)
| +--- project XXXXXXXX
| | +--- io.github.microutils:kotlin-logging-jvm -> 2.1.23 (*)
| | +--- org.slf4j:slf4j-api -> 2.0.9
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
| | +--- project XXXXXXXX
| | | +--- org.springframework.boot:spring-boot-dependencies:3.2.1
| | | | +--- org.glassfish.jaxb:jaxb-runtime:4.0.4 (c)
| | | | +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.1 (c)
| | | | +--- org.apache.groovy:groovy:4.0.16 -> 4.0.18 (c)
| | | | +--- org.apache.groovy:groovy-json:4.0.16 -> 4.0.18 (c)
| | | | +--- org.apache.groovy:groovy-xml:4.0.16 -> 4.0.18 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-joda:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3 (c)
| | | | +--- org.junit.jupiter:junit-jupiter:5.10.1 -> 5.10.2 (c)
| | | | +--- org.junit.platform:junit-platform-engine:1.10.1 -> 1.10.2 (c)
| | | | +--- org.junit.platform:junit-platform-launcher:1.10.1 -> 1.10.2 (c)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.21 -> 1.9.22 (c)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.21 (c)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.21 -> 1.9.22 (c)
| | | | +--- com.squareup.okhttp3:okhttp:4.12.0 (c)
| | | | +--- org.springframework:spring-tx:6.1.2 (c)
| | | | +--- org.springframework:spring-webmvc:6.1.2 (c)
| | | | +--- org.springframework.security:spring-security-test:6.2.1 (c)
| | | | +--- org.apache.commons:commons-lang3:3.13.0 (c)
| | | | +--- com.h2database:h2:2.2.224 (c)
| | | | +--- org.hamcrest:hamcrest:2.2 (c)
| | | | +--- com.zaxxer:HikariCP:5.0.1 (c)
| | | | +--- jakarta.annotation:jakarta.annotation-api:2.1.1 (c)
| | | | +--- jakarta.servlet:jakarta.servlet-api:6.0.0 (c)
| | | | +--- org.springframework.boot:spring-boot-test-autoconfigure:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-actuator:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-aop:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-data-jpa:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-security:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-test:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-web:3.2.1 (c)
| | | | +--- org.slf4j:slf4j-api:2.0.9 (c)
| | | | +--- org.yaml:snakeyaml:2.2 (c)
| | | | +--- org.springframework:spring-core:6.1.2 (c)
| | | | +--- org.springframework:spring-context:6.1.2 (c)
| | | | +--- org.springframework.boot:spring-boot:3.2.1 (c)
| | | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (c)
| | | | +--- org.glassfish.jaxb:jaxb-core:4.0.4 (c)
| | | | +--- jakarta.activation:jakarta.activation-api:2.1.2 (c)
| | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.15.3 (c)
| | | | +--- org.jetbrains.kotlin:kotlin-reflect:1.9.21 (c)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.21 (c)
| | | | +--- org.springframework:spring-beans:6.1.2 (c)
| | | | +--- org.springframework:spring-aop:6.1.2 (c)
| | | | +--- org.springframework:spring-expression:6.1.2 (c)
| | | | +--- org.springframework:spring-web:6.1.2 (c)
| | | | +--- org.springframework.security:spring-security-core:6.2.1 (c)
| | | | +--- org.springframework.security:spring-security-web:6.2.1 (c)
| | | | +--- org.springframework:spring-test:6.1.2 (c)
| | | | +--- org.springframework.boot:spring-boot-test:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-autoconfigure:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-logging:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-actuator-autoconfigure:3.2.1 (c)
| | | | +--- io.micrometer:micrometer-observation:1.12.1 (c)
| | | | +--- io.micrometer:micrometer-jakarta9:1.12.1 (c)
| | | | +--- org.aspectj:aspectjweaver:1.9.21 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-jdbc:3.2.1 (c)
| | | | +--- org.hibernate.orm:hibernate-core:6.4.1.Final (c)
| | | | +--- org.springframework.data:spring-data-jpa:3.2.1 (c)
| | | | +--- org.springframework:spring-aspects:6.1.2 (c)
| | | | +--- org.springframework.security:spring-security-config:6.2.1 (c)
| | | | +--- com.jayway.jsonpath:json-path:2.8.0 (c)
| | | | +--- net.minidev:json-smart:2.5.0 (c)
| | | | +--- org.assertj:assertj-core:3.24.2 (c)
| | | | +--- org.awaitility:awaitility:4.2.0 (c)
| | | | +--- org.mockito:mockito-core:5.7.0 (c)
| | | | +--- org.mockito:mockito-junit-jupiter:5.7.0 (c)
| | | | +--- org.skyscreamer:jsonassert:1.5.1 (c)
| | | | +--- org.xmlunit:xmlunit-core:2.9.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-json:3.2.1 (c)
| | | | +--- org.springframework.boot:spring-boot-starter-tomcat:3.2.1 (c)
| | | | +--- org.springframework:spring-jcl:6.1.2 (c)
| | | | +--- org.junit.jupiter:junit-jupiter-api:5.10.1 -> 5.10.2 (c)
| | | | +--- org.junit.jupiter:junit-jupiter-params:5.10.1 -> 5.10.2 (c)
| | | | +--- org.junit.jupiter:junit-jupiter-engine:5.10.1 -> 5.10.2 (c)
| | | | +--- org.junit.platform:junit-platform-commons:1.10.1 -> 1.10.2 (c)
| | | | +--- org.eclipse.angus:angus-activation:2.0.1 (c)
| | | | +--- org.glassfish.jaxb:txw2:4.0.4 (c)
| | | | +--- com.sun.istack:istack-commons-runtime:4.1.2 (c)
| | | | +--- org.springframework.security:spring-security-crypto:6.2.1 (c)
| | | | +--- ch.qos.logback:logback-classic:1.4.14 (c)
| | | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.21.1 (c)
| | | | +--- org.slf4j:jul-to-slf4j:2.0.9 (c)
| | | | +--- org.springframework.boot:spring-boot-actuator:3.2.1 (c)
| | | | +--- io.micrometer:micrometer-commons:1.12.1 (c)
| | | | +--- io.micrometer:micrometer-core:1.12.1 (c)
| | | | +--- org.springframework:spring-jdbc:6.1.2 (c)
| | | | +--- jakarta.persistence:jakarta.persistence-api:3.1.0 (c)
| | | | +--- jakarta.transaction:jakarta.transaction-api:2.0.1 (c)
| | | | +--- org.jboss.logging:jboss-logging:3.5.3.Final (c)
| | | | +--- com.fasterxml:classmate:1.6.0 (c)
| | | | +--- net.bytebuddy:byte-buddy:1.14.10 (c)
| | | | +--- org.springframework.data:spring-data-commons:3.2.1 (c)
| | | | +--- org.springframework:spring-orm:6.1.2 (c)
| | | | +--- net.bytebuddy:byte-buddy-agent:1.14.10 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.3 (c)
| | | | +--- org.apache.tomcat.embed:tomcat-embed-core:10.1.17 (c)
| | | | +--- org.apache.tomcat.embed:tomcat-embed-el:10.1.17 (c)
| | | | +--- org.apache.tomcat.embed:tomcat-embed-websocket:10.1.17 (c)
| | | | +--- ch.qos.logback:logback-core:1.4.14 (c)
| | | | \--- org.apache.logging.log4j:log4j-api:2.21.1 (c)
| | | +--- project XXXXXXXX
| | | +--- org.apache.groovy:groovy:4.0.18 (c)
| | | +--- org.apache.groovy:groovy-json:4.0.18 (c)
| | | +--- org.apache.groovy:groovy-xml:4.0.18 (c)
| | | +--- io.github.microutils:kotlin-logging-jvm:2.1.23 (c)
| | | +--- com.squareup.okhttp3:okhttp:4.12.0 (c)
| | | +--- org.spockframework:spock-core:2.4-M2-groovy-4.0 (c)
| | | +--- org.spockframework:spock-spring:2.4-M2-groovy-4.0 (c)
| | | +--- cglib:cglib-nodep:3.3.0 (c)
| | | +--- org.wiremock:wiremock-standalone:3.4.2 (c)
| | | +--- project XXXXXXXX
| | | +--- org.yaml:snakeyaml:2.0 -> 2.2 (c)
| | | +--- project XXXXXXXX
| | | +--- jakarta.servlet:jakarta.servlet-api -> 6.0.0 (c)
| | | \--- net.jpountz.lz4:lz4:1.3.0 (c)
| | +--- org.springframework:spring-core -> 6.1.2
| | | \--- org.springframework:spring-jcl:6.1.2
| | +--- org.springframework:spring-context -> 6.1.2
| | | +--- org.springframework:spring-aop:6.1.2
| | | | +--- org.springframework:spring-beans:6.1.2
| | | | | \--- org.springframework:spring-core:6.1.2 (*)
| | | | \--- org.springframework:spring-core:6.1.2 (*)
| | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | +--- org.springframework:spring-core:6.1.2 (*)
| | | +--- org.springframework:spring-expression:6.1.2
| | | | \--- org.springframework:spring-core:6.1.2 (*)
| | | \--- io.micrometer:micrometer-observation:1.12.1
| | | \--- io.micrometer:micrometer-commons:1.12.1
| | +--- org.springframework.boot:spring-boot -> 3.2.1
| | | +--- org.springframework:spring-core:6.1.2 (*)
| | | \--- org.springframework:spring-context:6.1.2 (*)
| | \--- com.fasterxml.jackson.core:jackson-databind -> 2.15.3
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3
| | \--- com.fasterxml.jackson.core:jackson-core:2.15.3
| +--- org.springframework.boot:spring-boot-starter -> 3.2.1
| | +--- org.springframework.boot:spring-boot:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:3.2.1
| | | \--- org.springframework.boot:spring-boot:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:3.2.1
| | | +--- ch.qos.logback:logback-classic:1.4.14
| | | | +--- ch.qos.logback:logback-core:1.4.14
| | | | \--- org.slf4j:slf4j-api:2.0.7 -> 2.0.9
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.21.1
| | | | +--- org.apache.logging.log4j:log4j-api:2.21.1
| | | | \--- org.slf4j:slf4j-api:1.7.36 -> 2.0.9
| | | \--- org.slf4j:jul-to-slf4j:2.0.9
| | | \--- org.slf4j:slf4j-api:2.0.9
| | +--- jakarta.annotation:jakarta.annotation-api:2.1.1
| | +--- org.springframework:spring-core:6.1.2 (*)
| | \--- org.yaml:snakeyaml:2.2
| +--- org.springframework.boot:spring-boot-starter-actuator -> 3.2.1
| | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-actuator-autoconfigure:3.2.1
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | | | \--- com.fasterxml.jackson:jackson-bom:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-joda:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3 (c)
| | | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.3 (c)
| | | | \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.3 (c)
| | | +--- org.springframework.boot:spring-boot-actuator:3.2.1
| | | | \--- org.springframework.boot:spring-boot:3.2.1 (*)
| | | +--- org.springframework.boot:spring-boot:3.2.1 (*)
| | | \--- org.springframework.boot:spring-boot-autoconfigure:3.2.1 (*)
| | +--- io.micrometer:micrometer-observation:1.12.1 (*)
| | \--- io.micrometer:micrometer-jakarta9:1.12.1
| | +--- io.micrometer:micrometer-core:1.12.1
| | | +--- io.micrometer:micrometer-commons:1.12.1
| | | +--- io.micrometer:micrometer-observation:1.12.1 (*)
| | | +--- org.hdrhistogram:HdrHistogram:2.1.12
| | | \--- org.latencyutils:LatencyUtils:2.0.3
| | +--- io.micrometer:micrometer-commons:1.12.1
| | \--- io.micrometer:micrometer-observation:1.12.1 (*)
| +--- org.springframework.boot:spring-boot-starter-aop -> 3.2.1
| | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | +--- org.springframework:spring-aop:6.1.2 (*)
| | \--- org.aspectj:aspectjweaver:1.9.21
| +--- org.springframework.boot:spring-boot-starter-security -> 3.2.1
| | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | +--- org.springframework:spring-aop:6.1.2 (*)
| | +--- org.springframework.security:spring-security-config:6.2.1
| | | +--- org.springframework.security:spring-security-core:6.2.1
| | | | +--- org.springframework.security:spring-security-crypto:6.2.1
| | | | +--- org.springframework:spring-aop:6.1.2 (*)
| | | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | | +--- org.springframework:spring-context:6.1.2 (*)
| | | | +--- org.springframework:spring-core:6.1.2 (*)
| | | | +--- org.springframework:spring-expression:6.1.2 (*)
| | | | \--- io.micrometer:micrometer-observation:1.12.1 (*)
| | | +--- org.springframework:spring-aop:6.1.2 (*)
| | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | +--- org.springframework:spring-context:6.1.2 (*)
| | | \--- org.springframework:spring-core:6.1.2 (*)
| | \--- org.springframework.security:spring-security-web:6.2.1
| | +--- org.springframework.security:spring-security-core:6.2.1 (*)
| | +--- org.springframework:spring-core:6.1.2 (*)
| | +--- org.springframework:spring-aop:6.1.2 (*)
| | +--- org.springframework:spring-beans:6.1.2 (*)
| | +--- org.springframework:spring-context:6.1.2 (*)
| | +--- org.springframework:spring-expression:6.1.2 (*)
| | \--- org.springframework:spring-web:6.1.2
| | +--- org.springframework:spring-beans:6.1.2 (*)
| | +--- org.springframework:spring-core:6.1.2 (*)
| | \--- io.micrometer:micrometer-observation:1.12.1 (*)
| +--- jakarta.annotation:jakarta.annotation-api -> 2.1.1
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
| +--- project XXXXXXXX
| +--- org.springframework:spring-tx -> 6.1.2
| | +--- org.springframework:spring-beans:6.1.2 (*)
| | \--- org.springframework:spring-core:6.1.2 (*)
| \--- org.yaml:snakeyaml -> 2.2
+--- project XXXXXXXX
| +--- io.github.microutils:kotlin-logging-jvm -> 2.1.23 (*)
| +--- org.springframework.boot:spring-boot-starter-data-jpa -> 3.2.1
| | +--- org.springframework.boot:spring-boot-starter-aop:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-starter-jdbc:3.2.1
| | | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | | +--- com.zaxxer:HikariCP:5.0.1
| | | | \--- org.slf4j:slf4j-api:1.7.30 -> 2.0.9
| | | \--- org.springframework:spring-jdbc:6.1.2
| | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | +--- org.springframework:spring-core:6.1.2 (*)
| | | \--- org.springframework:spring-tx:6.1.2 (*)
| | +--- org.hibernate.orm:hibernate-core:6.4.1.Final
| | | +--- jakarta.persistence:jakarta.persistence-api:3.1.0
| | | +--- jakarta.transaction:jakarta.transaction-api:2.0.1
| | | +--- org.jboss.logging:jboss-logging:3.5.0.Final -> 3.5.3.Final
| | | +--- org.hibernate.common:hibernate-commons-annotations:6.0.6.Final
| | | +--- io.smallrye:jandex:3.1.2
| | | +--- com.fasterxml:classmate:1.5.1 -> 1.6.0
| | | +--- net.bytebuddy:byte-buddy:1.14.7 -> 1.14.10
| | | +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.0 -> 4.0.1
| | | | \--- jakarta.activation:jakarta.activation-api:2.1.2
| | | +--- org.glassfish.jaxb:jaxb-runtime:4.0.2 -> 4.0.4
| | | | \--- org.glassfish.jaxb:jaxb-core:4.0.4
| | | | +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.1 (*)
| | | | +--- jakarta.activation:jakarta.activation-api:2.1.2
| | | | +--- org.eclipse.angus:angus-activation:2.0.1
| | | | | \--- jakarta.activation:jakarta.activation-api:2.1.2
| | | | +--- org.glassfish.jaxb:txw2:4.0.4
| | | | \--- com.sun.istack:istack-commons-runtime:4.1.2
| | | +--- jakarta.inject:jakarta.inject-api:2.0.1
| | | \--- org.antlr:antlr4-runtime:4.13.0
| | +--- org.springframework.data:spring-data-jpa:3.2.1
| | | +--- org.springframework.data:spring-data-commons:3.2.1
| | | | +--- org.springframework:spring-core:6.1.2 (*)
| | | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | | \--- org.slf4j:slf4j-api:2.0.2 -> 2.0.9
| | | +--- org.springframework:spring-orm:6.1.2
| | | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | | +--- org.springframework:spring-core:6.1.2 (*)
| | | | +--- org.springframework:spring-jdbc:6.1.2 (*)
| | | | \--- org.springframework:spring-tx:6.1.2 (*)
| | | +--- org.springframework:spring-context:6.1.2 (*)
| | | +--- org.springframework:spring-aop:6.1.2 (*)
| | | +--- org.springframework:spring-tx:6.1.2 (*)
| | | +--- org.springframework:spring-beans:6.1.2 (*)
| | | +--- org.springframework:spring-core:6.1.2 (*)
| | | +--- org.antlr:antlr4-runtime:4.13.0
| | | +--- jakarta.annotation:jakarta.annotation-api:2.0.0 -> 2.1.1
| | | \--- org.slf4j:slf4j-api:2.0.2 -> 2.0.9
| | \--- org.springframework:spring-aspects:6.1.2
| | \--- org.aspectj:aspectjweaver:1.9.20.1 -> 1.9.21
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
| +--- project XXXXXXXX
| +--- project XXXXXXXX
| +--- com.zaxxer:HikariCP -> 5.0.1 (*)
| \--- project XXXXXXXX
| +--- io.github.microutils:kotlin-logging-jvm -> 2.1.23 (*)
| +--- project XXXXXXXX
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
| +--- project XXXXXXXX
| \--- project XXXXXXXX
+--- project XXXXXXXX
| +--- io.github.microutils:kotlin-logging-jvm -> 2.1.23 (*)
| +--- jakarta.servlet:jakarta.servlet-api -> 6.0.0
| +--- org.springframework.boot:spring-boot-starter-web -> 3.2.1
| | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-starter-json:3.2.1
| | | +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| | | +--- org.springframework:spring-web:6.1.2 (*)
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.15.3
| | | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | | | \--- com.fasterxml.jackson:jackson-bom:2.15.3 (*)
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.3 (*)
| | | \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.3
| | | +--- com.fasterxml.jackson.core:jackson-core:2.15.3
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | | \--- com.fasterxml.jackson:jackson-bom:2.15.3 (*)
| | +--- org.springframework.boot:spring-boot-starter-tomcat:3.2.1
| | | +--- jakarta.annotation:jakarta.annotation-api:2.1.1
| | | +--- org.apache.tomcat.embed:tomcat-embed-core:10.1.17
| | | +--- org.apache.tomcat.embed:tomcat-embed-el:10.1.17
| | | \--- org.apache.tomcat.embed:tomcat-embed-websocket:10.1.17
| | | \--- org.apache.tomcat.embed:tomcat-embed-core:10.1.17
| | +--- org.springframework:spring-web:6.1.2 (*)
| | \--- org.springframework:spring-webmvc:6.1.2
| | +--- org.springframework:spring-aop:6.1.2 (*)
| | +--- org.springframework:spring-beans:6.1.2 (*)
| | +--- org.springframework:spring-context:6.1.2 (*)
| | +--- org.springframework:spring-core:6.1.2 (*)
| | +--- org.springframework:spring-expression:6.1.2 (*)
| | \--- org.springframework:spring-web:6.1.2 (*)
| +--- org.springframework:spring-webmvc -> 6.1.2 (*)
| +--- project XXXXXXXX
| +--- jakarta.xml.bind:jakarta.xml.bind-api -> 4.0.1 (*)
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
| +--- project XXXXXXXX
| +--- project XXXXXXXX
| +--- net.jpountz.lz4:lz4 -> 1.3.0
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> 2.15.3 (*)
| +--- com.fasterxml.jackson.datatype:jackson-datatype-joda -> 2.15.3
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3
| | +--- com.fasterxml.jackson.core:jackson-core:2.15.3
| | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | \--- joda-time:joda-time:2.10.14
| +--- com.fasterxml.jackson.module:jackson-module-kotlin -> 2.15.3
| | +--- com.fasterxml.jackson.core:jackson-databind:2.15.3 (*)
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.15.3
| | +--- org.jetbrains.kotlin:kotlin-reflect:1.5.32 -> 1.9.21
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.9.21 -> 1.9.22 (*)
| | \--- com.fasterxml.jackson:jackson-bom:2.15.3 (*)
| \--- org.glassfish.jaxb:jaxb-runtime -> 4.0.4 (*)
+--- com.squareup.okhttp3:okhttp -> 4.12.0
| +--- com.squareup.okio:okio:3.6.0
| | \--- com.squareup.okio:okio-jvm:3.6.0
| | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10 -> 1.9.21 (*)
| | \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10 -> 1.9.22 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21 -> 1.9.21 (*)
+--- org.apache.groovy:groovy -> 4.0.18 (*)
+--- org.apache.groovy:groovy-json -> 4.0.18
| +--- org.apache.groovy:groovy-bom:4.0.18 (*)
| \--- org.apache.groovy:groovy:4.0.18 (*)
+--- org.apache.groovy:groovy-xml -> 4.0.18
| +--- org.apache.groovy:groovy-bom:4.0.18 (*)
| \--- org.apache.groovy:groovy:4.0.18 (*)
+--- org.springframework.boot:spring-boot-starter-test -> 3.2.1
| +--- org.springframework.boot:spring-boot-starter:3.2.1 (*)
| +--- org.springframework.boot:spring-boot-test:3.2.1
| | \--- org.springframework.boot:spring-boot:3.2.1 (*)
| +--- org.springframework.boot:spring-boot-test-autoconfigure:3.2.1
| | +--- org.springframework.boot:spring-boot:3.2.1 (*)
| | +--- org.springframework.boot:spring-boot-test:3.2.1 (*)
| | \--- org.springframework.boot:spring-boot-autoconfigure:3.2.1 (*)
| +--- com.jayway.jsonpath:json-path:2.8.0
| | +--- net.minidev:json-smart:2.4.10 -> 2.5.0
| | | \--- net.minidev:accessors-smart:2.5.0
| | | \--- org.ow2.asm:asm:9.3
| | \--- org.slf4j:slf4j-api:1.7.36 -> 2.0.9
| +--- jakarta.xml.bind:jakarta.xml.bind-api:4.0.1 (*)
| +--- net.minidev:json-smart:2.5.0 (*)
| +--- org.assertj:assertj-core:3.24.2
| | \--- net.bytebuddy:byte-buddy:1.12.21 -> 1.14.10
| +--- org.awaitility:awaitility:4.2.0
| | \--- org.hamcrest:hamcrest:2.1 -> 2.2
| +--- org.hamcrest:hamcrest:2.2
| +--- org.junit.jupiter:junit-jupiter:5.10.1 -> 5.10.2 (*)
| +--- org.mockito:mockito-core:5.7.0
| | +--- net.bytebuddy:byte-buddy:1.14.9 -> 1.14.10
| | +--- net.bytebuddy:byte-buddy-agent:1.14.9 -> 1.14.10
| | \--- org.objenesis:objenesis:3.3
| +--- org.mockito:mockito-junit-jupiter:5.7.0
| | +--- org.mockito:mockito-core:5.7.0 (*)
| | \--- org.junit.jupiter:junit-jupiter-api:5.10.0 -> 5.10.2 (*)
| +--- org.skyscreamer:jsonassert:1.5.1
| | \--- com.vaadin.external.google:android-json:0.0.20131108.vaadin1
| +--- org.springframework:spring-core:6.1.2 (*)
| +--- org.springframework:spring-test:6.1.2
| | \--- org.springframework:spring-core:6.1.2 (*)
| \--- org.xmlunit:xmlunit-core:2.9.1
+--- org.springframework.boot:spring-boot-test-autoconfigure -> 3.2.1 (*)
+--- org.springframework.security:spring-security-test -> 6.2.1
| +--- org.springframework.security:spring-security-core:6.2.1 (*)
| +--- org.springframework.security:spring-security-web:6.2.1 (*)
| +--- org.springframework:spring-core:6.1.2 (*)
| \--- org.springframework:spring-test:6.1.2 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 (*)
+--- project XXXXXXXX
+--- cglib:cglib-nodep -> 3.3.0
+--- com.h2database:h2 -> 2.2.224
+--- org.wiremock:wiremock-standalone -> 3.4.2
\--- org.junit.platform:junit-platform-launcher -> 1.10.2
+--- org.junit.platform:junit-platform-engine:1.10.2 (*)
\--- org.apiguardian:apiguardian-api:1.1.2
(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree.
(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.
A web-based, searchable dependency report is available by adding the --scan option.
Additional context
No response
Describe the bug
Upgrading Spock 2.4-M1-groovy-4.0 to any version between 2.4-M2-groovy-4.0 and to 2.4-M5-groovy-4.0
We use a Spock extension to run specs within a certain (thread-local) context.
The Spock specs or features are annotated with an annotation
@WithTenantContext. The annotation is handled by theTenantContextExtension.The test application contains an initializing bean, verifying that the tenant context is not set during Spock initialization.
In the example code below, the assert
assert TenantContextHolder.currentTenant == nullsucceeds during all Spock versions up to2.4-M1-groovy-4.0, but fails since2.4-M2-groovy-4.0and newer.To Reproduce
Spec:
Test application:
Annotation:
Extension:
The
TenantContextProvideris implemented with code similar towhere
TenantContextHolderis a thread-local storage of some context.Expected behavior
The spec to succeed, no thread local context should be set during the setup of the spec (by the Spring extension).
Actual behavior
The assertion fails, because a thread-local context is set during spec initialization.
Java version
Java 11, or 17 or 21
Buildtool version
Gradle 8.5 until Gradle 8.13
What operating system are you using
Linux
Dependencies
Below is the dependency diagram for the
2.4-M2-groovy-4.0version. Newer dependency versions (also of other unrelated dependencies) shows the same behaviour as described in this issue.Additional context
No response