geantyref throws StackOverflowError in 2.4-M4-groovy-4.0
rgustafson-ie opened this issue · comments
Describe the bug
Tests which mock certain kinds of method signatures trigger a StackOverflowError from the geantyref library.
The stop of the stack from the entry into the Spock code looks like:
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)
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)
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)
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)
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)
at io.leangen.geantyref.GenericTypeReflector.mapTypeParameters(GenericTypeReflector.java:143)
at io.leangen.geantyref.GenericTypeReflector.getReturnType(GenericTypeReflector.java:644)
at io.leangen.geantyref.GenericTypeReflector.getReturnType(GenericTypeReflector.java:625)
at io.leangen.geantyref.GenericTypeReflector.getReturnType(GenericTypeReflector.java:635)
at org.spockframework.util.GenericTypeReflectorUtil.getReturnType(GenericTypeReflectorUtil.java:105)
at org.spockframework.mock.runtime.StaticMockMethod.getExactReturnType(StaticMockMethod.java:62)
at org.spockframework.mock.runtime.StaticMockMethod.getReturnType(StaticMockMethod.java:57)
at org.spockframework.mock.response.ConstantResponseGenerator.doRespond(ConstantResponseGenerator.java:37)
at org.spockframework.mock.response.SingleResponseGenerator.lambda$getResponseSupplier$0(SingleResponseGenerator.java:36)
at org.spockframework.mock.runtime.InteractionScope$1.lambda$accept$0(InteractionScope.java:62)
at org.spockframework.mock.runtime.MockController.handle(MockController.java:63)
at org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:84)
at org.spockframework.mock.runtime.JavaProxyMockInterceptorAdapter.invoke(JavaProxyMockInterceptorAdapter.java:36)
To Reproduce
This code demonstrates the geantyref issue when using the 1.3.16 version:
import io.leangen.geantyref.GenericTypeReflector;
public class Bug {
public static <E extends Enum<E>> E enumVar(E ignore) {
return null;
}
public static void main(String[] args) throws NoSuchMethodException {
var declaringType = Bug.class;
var method = declaringType.getMethod("enumVar", Enum.class);
GenericTypeReflector.getReturnType(method, declaringType);
}
}
This bug class and my Spock tests pass when using geantyref 2.0.0 or 2.0.1. I could not find release notes for these versions.
Expected behavior
No StackOverflowError should happen.
Actual behavior
StackOverflowError happens.
Java version
Java 17
Buildtool version
Maven
What operating system are you using
Mac
Dependencies
The Spock relevant bits:
[INFO] +- org.spockframework:spock-core:jar:2.4-M5-groovy-4.0:test
[INFO] | +- org.junit.platform:junit-platform-engine:jar:1.10.5:test
[INFO] | | +- org.opentest4j:opentest4j:jar:1.3.0:test
[INFO] | | +- org.junit.platform:junit-platform-commons:jar:1.10.5:test
[INFO] | | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | \- io.leangen.geantyref:geantyref:jar:1.3.16:test
Additional context
No response
This was a mistake on my part. I thought I was using M5, but I had actually downgraded to M4, which actually uses 1.3.15 of the library. If I use M5 for this Bug class it works on 1.13.16, although my Spock tests fail for a different Spock issue for which I'm awaiting the M6 release (hence my downgrade to M4). I'll see if I can proceed with M4 and a bump to 1.13.16 for now.