From ae305f8c4e86d0725128f5792dd4bd61e9f32dad Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 9 May 2023 10:18:52 +0200 Subject: [PATCH] Don't generate stacktrace in CollectionTerminatedException (#12270) CollectionTerminatedException is always caught and never exposed to users so there's no point in filling in a stack-trace for it. --- lucene/CHANGES.txt | 3 ++- .../apache/lucene/search/CollectionTerminatedException.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 45bfa91627c1..65ed9ea378fb 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -19,7 +19,8 @@ Improvements Optimizations --------------------- -(No changes) + +* GITHUB#12270 Don't generate stacktrace in CollectionTerminatedException. (Armin Braun) Bug Fixes --------------------- diff --git a/lucene/core/src/java/org/apache/lucene/search/CollectionTerminatedException.java b/lucene/core/src/java/org/apache/lucene/search/CollectionTerminatedException.java index 2a7e04447481..89f14fff20bc 100644 --- a/lucene/core/src/java/org/apache/lucene/search/CollectionTerminatedException.java +++ b/lucene/core/src/java/org/apache/lucene/search/CollectionTerminatedException.java @@ -31,4 +31,10 @@ public final class CollectionTerminatedException extends RuntimeException { public CollectionTerminatedException() { super(); } + + @Override + public Throwable fillInStackTrace() { + // never re-thrown so we can save the expensive stacktrace + return this; + } }