From a53876d6b18a37fc741a0f7f716112aeee9cb814 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 11 May 2021 12:14:58 +0100 Subject: [PATCH] Fix stackoverflow in ArgumentsAreDifferent reporting 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. --- .../mockito/exceptions/verification/ArgumentsAreDifferent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java b/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java index 1be1ace19e..ac572f40a5 100644 --- a/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java +++ b/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java @@ -31,6 +31,6 @@ public ArgumentsAreDifferent(String message, String wanted, String actual) { @Override public String getMessage() { - return removeFirstLine(super.toString()); + return removeFirstLine(super.getMessage()); } }