You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2022/08/17 09:30:56 UTC
[logging-log4j2] 02/03: LOG4J2-3556 Fix stack trace truncation matcher regex.
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch LOG4J2-3556
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit a0c24a5a398d21e274531cdb8a6eac21b389d669
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Wed Aug 17 11:26:16 2022 +0200
LOG4J2-3556 Fix stack trace truncation matcher regex.
---
.../layout/template/json/resolver/StackTraceStringResolver.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/StackTraceStringResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/StackTraceStringResolver.java
index 4e72d1a718..92c2d33252 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/StackTraceStringResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/StackTraceStringResolver.java
@@ -74,8 +74,10 @@ final class StackTraceStringResolver implements StackTraceResolver {
return regexes
.stream()
.map(regex -> Pattern.compile(
- "^.*(" + regex + ")(.*)$",
- Pattern.MULTILINE | Pattern.DOTALL))
+ ".*?" + // Make `.*` lazy with `?` suffix, since we want to find the _first_ match of `regex`.
+ regex + // Match the user input.
+ "(.*)", // Group that is to be truncated.
+ Pattern.DOTALL))
.collect(Collectors.toList());
}