This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch TIKA-4809-stage-9 in repository https://gitbox.apache.org/repos/asf/tika.git
commit 425527810187f2a2bcd42e9bf24e54c03fe2b1d5 Author: tallison <[email protected]> AuthorDate: Tue Aug 11 08:15:29 2026 -0400 TIKA-4809: Move trimMessage to tika-eval-core, its only consumer --- .../apache/tika/eval/core/util/EvalExceptionUtils.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tika-eval/tika-eval-core/src/main/java/org/apache/tika/eval/core/util/EvalExceptionUtils.java b/tika-eval/tika-eval-core/src/main/java/org/apache/tika/eval/core/util/EvalExceptionUtils.java index 3b94547184..c364e367af 100644 --- a/tika-eval/tika-eval-core/src/main/java/org/apache/tika/eval/core/util/EvalExceptionUtils.java +++ b/tika-eval/tika-eval-core/src/main/java/org/apache/tika/eval/core/util/EvalExceptionUtils.java @@ -21,8 +21,6 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import org.apache.tika.utils.ExceptionUtils; - public class EvalExceptionUtils { //these remove runtime info from the stacktraces so @@ -30,14 +28,27 @@ public class EvalExceptionUtils { private final static Pattern CAUSED_BY_SNIPPER = Pattern.compile("(Caused by: [^:]+):[^\\r\\n]+"); + //strips the exception message off the first line, so that the same cause with + //differing runtime detail collapses to one entry. Was ExceptionUtils.trimMessage in + //tika-core; moved here, its only consumer, when tika-server stopped parsing traces. + private final static Pattern MSG_PATTERN = Pattern.compile(":[^\\r\\n]+"); + public static String normalize(String stacktrace) { if (StringUtils.isBlank(stacktrace)) { return ""; } - String sortTrace = ExceptionUtils.trimMessage(stacktrace); + String sortTrace = trimMessage(stacktrace); Matcher matcher = CAUSED_BY_SNIPPER.matcher(sortTrace); sortTrace = matcher.replaceAll("$1"); return sortTrace.replaceAll("org.apache.tika.", "o.a.t."); } + + private static String trimMessage(String trace) { + Matcher msgMatcher = MSG_PATTERN.matcher(trace); + if (msgMatcher.find()) { + return msgMatcher.replaceFirst(""); + } + return trace; + } }
