-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix stackoverflow in ArgumentsAreDifferent reporting #2292
Conversation
When using Mockito without opentest4j, reporting an ArgumentsAreDifferent exception would throw a StackOverflowError when attempting to obtain the message from the exception. The root problem was that super.toString() would call its own getMessage(). Instead, we should obtain the message from the super, to avoid the circular call.
Note that I tried to create a regression test for this, but sadly was unable to. To make the integration test work, we would need to exclude both opentest4j and junit4. While that would technically be possible, Gradle wouldn't be able to pick up a test that is not annotated with
BasicVerificationTest would reproduce the issue and that the fix is making the test pass as expected.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we get rid of removeFirstLine
? Otherwise we might be losing first line of the message.
Are all of our implementations are doing this: mockito/src/main/java/org/mockito/exceptions/verification/opentest4j/ArgumentsAreDifferent.java Line 38 in 067ff24
mockito/src/main/java/org/mockito/exceptions/verification/junit/ArgumentsAreDifferent.java Line 38 in 067ff24
I am not sure what the effect of the removal is. Can we separate that change out, to unblock non-opentest4j users and figure out what the impact of removing |
Ok, let's move on. If all tests pass with your change, we should be good to go. |
When using Mockito without opentest4j, reporting an
ArgumentsAreDifferent exception would throw a StackOverflowError when
attempting to obtain the message from the exception.
The root problem was that super.toString() would call its own
getMessage(). Instead, we should obtain the message from the super, to
avoid the circular call.