Skip to content

Fix PrintStackTraceToLogError breaking stacktrace-to-string methods#282

Merged
timtebeek merged 2 commits intomainfrom
fix/printstacktrace-printwriter-guard
Mar 1, 2026
Merged

Fix PrintStackTraceToLogError breaking stacktrace-to-string methods#282
timtebeek merged 2 commits intomainfrom
fix/printstacktrace-printwriter-guard

Conversation

@timtebeek
Copy link
Member

@timtebeek timtebeek commented Mar 1, 2026

Summary

Test plan

  • New test doesNotReplacePrintStackTraceWithPrintWriterArgument asserts no transformation for PrintWriter arguments
  • Existing useSlf4j and supportLombokLogAnnotations tests still pass (they verify System.err/System.out args are transformed)
  • Full ./gradlew check passes

The recipe was transforming all `printStackTrace()` calls including those
that intentionally capture a stack trace to a string via StringWriter/
PrintWriter. Now only transforms no-arg calls or calls with System.err/
System.out arguments.

Fixes #281
@timtebeek timtebeek added the bug Something isn't working label Mar 1, 2026
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Mar 1, 2026
@timtebeek timtebeek merged commit 6618dfa into main Mar 1, 2026
1 check passed
@timtebeek timtebeek deleted the fix/printstacktrace-printwriter-guard branch March 1, 2026 19:31
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Mar 1, 2026
mergify bot added a commit to robfrank/linklift that referenced this pull request Mar 10, 2026
…rom 3.24.0 to 3.25.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-logging-frameworks](https://github.com/openrewrite/rewrite-logging-frameworks) from 3.24.0 to 3.25.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-logging-frameworks's releases](https://github.com/openrewrite/rewrite-logging-frameworks/releases).*

> 3.25.0
> ------
>
> What's Changed
> --------------
>
> * Add StringFormat, MessageFormat, and RemoveUnnecessaryLogLevelGuards SLF4J recipes. by [`@​motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#280](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/280)
> * Fix PrintStackTraceToLogError breaking stacktrace-to-string methods by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#282](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/282)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.24.0...v3.25.0>


Commits

* [`6618dfa`](openrewrite/rewrite-logging-frameworks@6618dfa) Fix PrintStackTraceToLogError breaking stacktrace-to-string methods ([#282](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/282))
* [`2f457be`](openrewrite/rewrite-logging-frameworks@2f457be) Add StringFormat, MessageFormat, and RemoveUnnecessaryLogLevelGuards SLF4J re...
* See full diff in [compare view](openrewrite/rewrite-logging-frameworks@v3.24.0...v3.25.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-logging-frameworks&package-manager=maven&previous-version=3.24.0&new-version=3.25.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PrintStackTraceToLogError breaks stacktrace-to-string method

1 participant