mockito: Stackoverflow error when upgrading to v3.5.2
I tried to upgrade from Mockito v3.4.6 to v3.5.2 and I’m getting a stackoverflow error (same error with v3.5.0) when running some tests (not all of them, just a few ; even in the same class : some tests pass and others don’t).
Stacktrace :
java.lang.StackOverflowError
at java.base/java.lang.ThreadLocal.get(ThreadLocal.java:163)
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.lambda$new$3(InlineByteBuddyMockMaker.java:260)
at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.handleConstruction(MockMethodAdvice.java:176)
at org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.handleConstruction(MockMethodDispatcher.java:53)
at java.base/java.lang.Throwable.<init>(Throwable.java)
at java.base/java.lang.Exception.<init>(Exception.java:66)
at java.base/java.lang.RuntimeException.<init>(RuntimeException.java:62)
at java.base/java.lang.ClassCastException.<init>(ClassCastException.java:58)
at java.base/java.lang.Throwable.<init>(Throwable.java)
at java.base/java.lang.Exception.<init>(Exception.java:66)
at java.base/java.lang.RuntimeException.<init>(RuntimeException.java:62)
at java.base/java.lang.ClassCastException.<init>(ClassCastException.java:58)
at java.base/java.lang.Throwable.<init>(Throwable.java)
at java.base/java.lang.Exception.<init>(Exception.java:66)
...
I didn’t succeed in reproduce the error in a small project, but I’ll spend more time to try and post the sources here when/if I have a reproducible case.
Environment :
- Mockito v3.5.2
- JUnit v5.6.2
- Java :
openjdk version “11.0.8” 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
- Maven : v3.6.0 (tests are run by the maven-surefire plugin)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (9 by maintainers)
Commits related to this issue
- Initializes classes prior to instrumentation to avoid uncontrolled code execution. Fixes \# #2011 — committed to mockito/mockito by raphw 4 years ago
@raphw Thank you for the fix and the time spent on this. It works great !