Skip to content

Commit 2fd619c

Browse files
DaveCTurnerjfreden
authored andcommitted
Fix stack trace in ActionListener#assertOnce (#124672)
In #112380 we changed this `assert` to yield a `String` on failure rather than the original `ElasticsearchException`, which means we don't see the original completion's stack trace any more. This commit reinstates the lost stack trace.
1 parent 2ddccfd commit 2fd619c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/main/java/org/elasticsearch/action/ActionListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ static <Response> ActionListener<Response> assertOnce(ActionListener<Response> d
401401

402402
private void assertFirstRun() {
403403
var previousRun = firstCompletion.compareAndExchange(null, new ElasticsearchException("executed already"));
404-
assert previousRun == null : "[" + delegate + "] " + previousRun; // reports the stack traces of both completions
404+
assert previousRun == null
405+
// reports the stack traces of both completions
406+
: new AssertionError("[" + delegate + "]", previousRun);
405407
}
406408

407409
@Override

0 commit comments

Comments
 (0)