Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflow while mocking a ThreadLocal on Mockito 5.1.1 #2905

Closed
robertotru opened this issue Feb 8, 2023 · 0 comments · Fixed by #2908
Closed

StackOverflow while mocking a ThreadLocal on Mockito 5.1.1 #2905

robertotru opened this issue Feb 8, 2023 · 0 comments · Fixed by #2908

Comments

@robertotru
Copy link
Contributor

robertotru commented Feb 8, 2023

Hello Folks,

I'm upgrading Mockito in a Java application from 4.9.0 to 5.1.1. We are on JDK 11 (I personally use Temurin 11.0.13).

So, I've a test failing due to a StackOverflow

java.lang.StackOverflowError
	at org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.get(MockMethodDispatcher.java:34)
	at java.base/java.lang.ThreadLocal.get(ThreadLocal.java:162)
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice$SelfCallInfo.checkSelfCall(MockMethodAdvice.java:368)
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.isMocked(MockMethodAdvice.java:171)

This happens when we mock a class that extends ThreadLocal. But I verified that it happens also by mocking ThreadLocal as well.

Sounds like a bug, but you are the experts here.

Best regards,
Roberto

robertotru pushed a commit to robertotru/mockito that referenced this issue Feb 8, 2023
robertotru pushed a commit to robertotru/mockito that referenced this issue Feb 9, 2023
robertotru pushed a commit to robertotru/mockito that referenced this issue Feb 9, 2023
TimvdLippe pushed a commit that referenced this issue Feb 11, 2023
Fixes #2905

Co-authored-by: Roberto Trunfio <Roberto.Trunfio@appway.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant