Skip to content

ParameterizedLogging does not retain argument order when there is both String concatenation and existing parameterized arguments #236

Closed

Description

@sergeykad

What version of OpenRewrite are you using?

I am using this Gradle init script:

initscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2" }
    }
    dependencies { classpath("org.openrewrite:plugin:7.10.0") }
}
rootProject {
    plugins.apply(org.openrewrite.gradle.RewritePlugin)
    dependencies {
        rewrite("org.openrewrite.recipe:rewrite-logging-frameworks:3.11.0")
    }
    rewrite {
        activeRecipe("org.openrewrite.java.logging.slf4j.ParameterizedLogging")
        setExportDatatables(true)
    }
    afterEvaluate {
        if (repositories.isEmpty()) {
            repositories {
                mavenCentral()
            }
        }
    }
}

How are you running OpenRewrite?

gradle --init-script init.gradle rewriteRun

What is the smallest, simplest way to reproduce the problem?

@Slf4j
class A {
    void foo(String bar) {
        log.info("Some logging {} with string concatination: " + String.join(",", indexPrefix), esHost);
    }
}

What did you expect to see?

@Slf4j
class A {
    void foo(String bar) {
        log.info("Some logging {} with string concatination: {}", esHost, String.join(",", indexPrefix));
    }
}

What did you see instead?

@Slf4j
class A {
    void foo(String bar) {
        log.info("Some logging {} with string concatination: {}", String.join(",", indexPrefix), esHost);
    }
}

What is the full stack trace of any errors you encountered?

No errors. Just changed the order of the log parameters.

Are you interested in [contributing a fix to OpenRewrite]

No

Activity

  1. added
    bug
    on Jul 17, 2025
  2. changed the title [-]parameterizedlogging does not handle correctly mixed cases[/-] [+]ParameterizedLogging does not retain argument order when there is both String concatenation and existing parameterized arguments[/+] on Jul 17, 2025
  3. moved this to Backlog in OpenRewriteon Jul 17, 2025
  4. added a commit that references this issue on Jul 17, 2025
    0b4da49
  5. timtebeek commented on Jul 17, 2025

    @timtebeek
    Member
  6. added a commit that references this issue on Jul 17, 2025
    cc1dd4f
  7. moved this from Backlog to Done in OpenRewriteon Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions