StackOverflowError in a Mock call
Describe the bug
- We have a test where the single method mocked collaborator is called three times in a row with slightly different parameters.
- This changed behavior was introduced while updating from
2.4-M1-groovy-4.0tov2.4-m2-groovy-4.0 - We use Maven 3.9.6, Java release is Temurin-17.0.10+7, test fails on both Linux Debian 12 as well as on macOS 14.3.1 (23D60).
- The first method call does succeed but the second leads to a StackOverflowError:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.034 s <<< FAILURE! -- in org.example.ValidatorTest
5605 [ERROR] org.example.ValidatorTest.Overflow? -- Time elapsed: 1.017 s <<< ERROR!
java.lang.StackOverflowError
at java.base/java.lang.Class.getExecutableTypeAnnotationBytes(Class.java:3451)
at java.base/java.lang.System$2.getRawExecutableTypeAnnotations(System.java:2367)
at io.leangen.geantyref.VarMap.map(VarMap.java:98)
at io.leangen.geantyref.VarMap.map(VarMap.java:115)
at io.leangen.geantyref.VarMap.map(VarMap.java:148)
at io.leangen.geantyref.VarMap.map(VarMap.java:98)
- I will link a reproducer.
To Reproduce
See https://github.com/mfriedenhagen/spock-stackoverflowerror
Expected behavior
Test runs successfully
Actual behavior
Test fails when using v2.4-m2-groovy-4.0
Java version
openjdk version "17.0.10" 2024-01-16 OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7) OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode)
Buildtool version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae) Maven home: /usr/local/Cellar/maven/3.9.6/libexec Java version: 17.0.10, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: de_DE, platform encoding: UTF-8 OS name: "mac os x", version: "14.3.1", arch: "x86_64", family: "mac"
What operating system are you using
Mac
Dependencies
org.example:spock-stackoverflowerro:jar:1.0-SNAPSHOT +- net.bytebuddy:byte-buddy:jar:1.14.12:test +- org.mockito:mockito-core:jar:5.10.0:test | +- net.bytebuddy:byte-buddy-agent:jar:1.14.11:test | - org.objenesis:objenesis:jar:3.3:test - org.spockframework:spock-core:jar:2.4-M2-groovy-4.0:test +- org.apache.groovy:groovy:jar:4.0.18:test +- org.junit.platform:junit-platform-engine:jar:1.10.2:test | +- org.opentest4j:opentest4j:jar:1.3.0:test | +- org.junit.platform:junit-platform-commons:jar:1.10.2:test | - org.apiguardian:apiguardian-api:jar:1.1.2:test +- org.hamcrest:hamcrest:jar:2.2:test - io.leangen.geantyref:geantyref:jar:1.3.15:test
Additional context
No response
I will have a look at that next week. It has probably something to do with the dependency change from gentyref to geantyref in 2.4-M2.
This is an issue in the geantyref library. I have opened an issue there: https://github.com/leangen/geantyref/issues/27
This is fixed with update of dependency geantyref to 1.3.16.