Skip to content

Conversation

@jtduffy
Copy link
Contributor

@jtduffy jtduffy commented Sep 24, 2025

Overview

Resolves #2472

In the logging framework instrumentation modules, the stack trace lines are truncated after the loop that generates the stack trace strings has completed.

return String.join("\n", lines.subList(0, Math.min(lines.size(), MAX_STACK_SIZE)));

We ran into an issue where a bug in a monitored app created millions of lines via some sort of recursive caused-by assignment. This caused a OOM because of the number of Strings created.

The modules should check the number of lines added to the list as the loop runs to prevent this issue in the future. Note that the String.join() call will remain as-is, since we create and add all the stacktrace lines for the current Throwable in one operation.

Modules:

java-logging-jdk8
apache-log4j-2.11
apache-log4j-1
apache-log4j-2.6
glassfish-jul-extension-7
logback-classic-1.2

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.42%. Comparing base (5a1e4c3) to head (b2a16d7).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2498      +/-   ##
============================================
- Coverage     70.44%   70.42%   -0.02%     
+ Complexity    10052    10050       -2     
============================================
  Files           845      845              
  Lines         40762    40774      +12     
  Branches       6184     6186       +2     
============================================
+ Hits          28713    28716       +3     
- Misses         9258     9262       +4     
- Partials       2791     2796       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jtduffy jtduffy merged commit f15b4ae into main Oct 1, 2025
223 of 224 checks passed
@jtduffy jtduffy deleted the logging-statck-size-fix branch October 1, 2025 19:19
@kmudduluru kmudduluru moved this from Triage to Code Complete/Done in Java Engineering Board Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Logging framework instrumentation: Move stacktrace length check to loop condition

4 participants