openrewrite / rewrite-logging-frameworks

OpenRewrite recipes for assisting with Java logging migration tasks.
Apache License 2.0
25 stars 20 forks source link

Issue discovered on `log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventAdapter.java` with `Parameterize logging statements` #130

Open JLLeitschuh opened 9 months ago

JLLeitschuh commented 9 months ago

Problem

Reformatting occurs when no other modifications are made.

Expected behavior

When no changes are made to a logging callsite, no modifications should occur to the formatting.

Example diff

From: log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventAdapter.java

      return (Long) getStartTime.invoke(runtimeMXBean);
} catch (final Throwable t) {
StatusLogger.getLogger()
-                    .error(
-                            "Unable to call ManagementFactory.getRuntimeMXBean().getStartTime(), "
-                                    + "using system time for OnStartupTriggeringPolicy",
-                            t);
+                    .error("Unable to call ManagementFactory.getRuntimeMXBean().getStartTime(), using system time for OnStartupTriggeringPolicy", t);
// We have little option but to declare "now" as the beginning of time.
return System.currentTimeMillis();
}

Recipes in example diff:

References:

timtebeek commented 9 months ago

Do you mean to say that final t); should remain on it's own line?

JLLeitschuh commented 9 months ago

The string wasn't modified at all, I think that no change should have been generated as there was no parameterization performed here