Skip to content

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

@sergeykad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions