Fix re-escaping of control characters when rebuilding Java string literals in logging recipes.#293
Merged
timtebeek merged 1 commit intoMay 28, 2026
Conversation
…erals in logging recipes.
936ea8f to
b5d5831
Compare
mergify Bot
added a commit
to robfrank/linklift
that referenced
this pull request
Jun 4, 2026
…rom 3.27.2 to 3.29.0 [skip ci] Bumps [org.openrewrite.recipe:rewrite-logging-frameworks](https://github.com/openrewrite/rewrite-logging-frameworks) from 3.27.2 to 3.29.0. Release notes *Sourced from [org.openrewrite.recipe:rewrite-logging-frameworks's releases](https://github.com/openrewrite/rewrite-logging-frameworks/releases).* > 3.29.0 > ------ > > What's Changed > -------------- > > * Regenerate recipes.csv by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#292](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/292) > * Fix re-escaping of control characters when rebuilding Java string literals in logging recipes. by [`@motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#293](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/293) > * Add Log4j2IsEnabledToSlf4j Refaster recipe to convert isEnabled(Level) level guards to SLF4J isXEnabled() calls. by [`@motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#294](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/294) > > **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.28.0...v3.29.0> > > 3.28.0 > ------ > > What's Changed > -------------- > > * Renew log4j 1.2.17 reference suppression to 2026-06-01 by [`@Jenson3210`](https://github.com/Jenson3210) in [openrewrite/rewrite-logging-frameworks#287](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/287) > * Update log4j-api TypeTable to 2.26.0 by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#288](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/288) > * Preserve formatting when ParameterizedLogging has nothing to parameterize by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#290](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/290) > > **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.27.0...v3.28.0> > > v3.27.3 > ------- > > What's Changed > -------------- > > * OpenRewrite [v8.81.6](https://github.com/openrewrite/rewrite/releases/tag/v8.81.6) > * Fix IndexOutOfBoundsException when JUL placeholders exceed argument count by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#284](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/284) > * Fix exception consumed by format placeholder in CompleteExceptionLogging by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#285](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/285) > > **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.26.0...v3.27.3> Commits * [`944b9c2`](openrewrite/rewrite-logging-frameworks@944b9c2) Add Log4j2IsEnabledToSlf4j Refaster recipe to convert isEnabled(Level) level ... * [`246f4d3`](openrewrite/rewrite-logging-frameworks@246f4d3) Fix re-escaping of control characters when rebuilding Java string literals in... * [`d5537a4`](openrewrite/rewrite-logging-frameworks@d5537a4) Update Gradle wrapper 9.5.1 * [`58e431b`](openrewrite/rewrite-logging-frameworks@58e431b) Regenerate recipes.csv ([#292](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/292)) * [`28afd35`](openrewrite/rewrite-logging-frameworks@28afd35) Remove explicit test dependencies * [`14f50ad`](openrewrite/rewrite-logging-frameworks@14f50ad) Preserve formatting when ParameterizedLogging has nothing to parameterize ([#2](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/2)... * [`32e22cb`](openrewrite/rewrite-logging-frameworks@32e22cb) Update log4j-api TypeTable to 2.26.0 ([#288](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/288)) * [`b7824c6`](openrewrite/rewrite-logging-frameworks@b7824c6) OpenRewrite recipe best practices * [`43fc6c2`](openrewrite/rewrite-logging-frameworks@43fc6c2) Renew log4j 1.2.17 reference suppression to 2026-06-01 ([#287](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/287)) * See full diff in [compare view](openrewrite/rewrite-logging-frameworks@v3.27.2...v3.29.0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
When SLF4J logging recipes rebuild a Java string literal from a decoded value, escape sequences were only partially re-applied:
\and"were re-escaped, but decoded control characters (\b \t \n \f \r) were emitted raw, producing invalid/unreadable source. Added a sharedJavaStringEscapes.escapeJavaStringContenthelper that re-escapes.What's your motivation?
String.format("a\nb\t%s", x)was being rewritten to source containing literal newlines/tabs, breaking compilation. The bug existed inStringFormatToParameterizedLoggingand, identically, inJulParameterizedArguments.Anything in particular you'd like reviewers to focus on?
The escaping policy in
JavaStringEscapes: it intentionally does not\u-escape printable non-ASCII (unlike commons-textescapeJava), to keep i18n log messages readable. Only control chars and\/"are escaped.Anyone you would like to review specifically?
@timtebeek
Have you considered any alternatives or workarounds?
Considered
org.apache.commons.text.StringEscapeUtils.escapeJava.