Skip to content

Add clear_return_stacks default for coroutines modules. - #3011

Draft
sharvath-newrelic wants to merge 2 commits into
change_kotlin_ignoresfrom
evaluate-properties-per-module
Draft

Add clear_return_stacks default for coroutines modules.#3011
sharvath-newrelic wants to merge 2 commits into
change_kotlin_ignoresfrom
evaluate-properties-per-module

Conversation

@sharvath-newrelic

@sharvath-newrelic sharvath-newrelic commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR defaults clear_return_stacks (the fix for AIOOBE when weaving Kotlin coroutine bytecode, e.g. Ktor's invokeSuspend continuations) to on for our Kotlin-coroutines/Ktor instrumentation modules (total of 8), so it applies automatically at runtime instead of requiring -Dnewrelic.config.class_transformer.clear_return_stacks=true to be set manually.

An explicitly-set system property (true or false) still overrides the per-module default in either direction, so existing behavior for anyone already using the global flag is unchanged. Every other instrumentation module keeps its current default (false).

ClassWeaverService matches each module's Implementation-Title against a hardcoded allow-list and sets clearReturnStacksDefault on that module's WeavePackageConfig at load time. That config is threaded through ClassWeave -> MethodProcessors -> MethodCallInlinerAdapter, so a future per-module default consumed at the same depth just needs a new getter on WeavePackageConfig.

Related Github Issue

Resolves #2981

Testing

6 new tests have been added to attend to permutations on defaulting system properties.

@codecov-commenter

codecov-commenter commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.73%. Comparing base (2fc181f) to head (591d8ae).

Files with missing lines Patch % Lines
...a/com/newrelic/weave/MethodCallInlinerAdapter.java 66.66% 4 Missing ⚠️
...main/java/com/newrelic/weave/MethodProcessors.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##             change_kotlin_ignores    #3011      +/-   ##
===========================================================
- Coverage                    70.88%   70.73%   -0.15%     
+ Complexity                   10680    10674       -6     
===========================================================
  Files                          874      880       +6     
  Lines                        42997    43031      +34     
  Branches                      6503     6507       +4     
===========================================================
- Hits                         30479    30439      -40     
- Misses                        9578     9651      +73     
- Partials                      2940     2941       +1     

☔ View full report in Codecov by Harness.
📢 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.

@sharvath-newrelic sharvath-newrelic moved this from Triage to Needs Review in Java Engineering Board Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants