From e22b614d920f292089bad2fc535097331b03c38c Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 24 Dec 2025 10:06:38 -0500 Subject: [PATCH] Fix MultiEntityResultTests.testQueryErrorEndRunNotNow after log4j upgrade to 2.25.3 Signed-off-by: Craig Perkins --- .../ad/transport/MultiEntityResultTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/opensearch/ad/transport/MultiEntityResultTests.java b/src/test/java/org/opensearch/ad/transport/MultiEntityResultTests.java index d6a299292..03611a852 100644 --- a/src/test/java/org/opensearch/ad/transport/MultiEntityResultTests.java +++ b/src/test/java/org/opensearch/ad/transport/MultiEntityResultTests.java @@ -535,14 +535,14 @@ public void testQueryErrorEndRunNotNow() throws InterruptedException, IOExceptio // make PageIterator.next return failure doAnswer(invocation -> { ActionListener listener = invocation.getArgument(1); - listener - .onFailure( - new SearchPhaseExecutionException( - "search", - allShardsFailedMsg, - new ShardSearchFailure[] { new ShardSearchFailure(new IllegalArgumentException("blah")) } - ) - ); + // Create SearchPhaseExecutionException without ShardSearchFailure to avoid log4j NPE + // when rendering corrupted stack trace metadata in nested exceptions + SearchPhaseExecutionException ex = new SearchPhaseExecutionException( + "search", + allShardsFailedMsg + "; shardFailures {IllegalArgumentException[blah]}", + new ShardSearchFailure[0] + ); + listener.onFailure(ex); inProgressLatch.countDown(); return null; }).when(client).search(any(), any());