Skip to content

Replace the Log4j setLevel Refaster template with its generated recipe - #304

Merged
kmccarp merged 1 commit into
mainfrom
log4j1-imperative
Sep 2, 2026
Merged

kmccarp merged 1 commit into
mainfrom
log4j1-imperative

Conversation

@kmccarp

@kmccarp kmccarp commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Background / problem

The vulnerability scan flags log4j:log4j 1.2.17 in this repo with six CRITICAL-rated Log4j 1.x advisories. The jar was on compileClasspath for exactly one reason: LoggerSetLevelToConfigurator was a Refaster template whose @BeforeTemplate signature names org.apache.log4j.Logger and org.apache.log4j.Level as parameter types, so the compiler needed the classes. Every other Log4j 1.x reference in the repo is a string, which needs nothing at compile time.

Keeping the jar meant keeping a repo-local suppressions.xml for it and renewing that suppression every month. It lapsed today.

Solution

Replaces the Refaster template with the imperative recipe rewrite-templating generates from it, committed as ordinary source. With no compile-time consumer left, the compileOnly("log4j:log4j:1.+") dependency and the suppressions.xml that existed for it are both deleted.

Also adds the Code Genome Project to pluginManagement, since rewrite-build-gradle-plugin 2.23.2 depends on rewrite releases published only there and the build cannot resolve otherwise. The block is skipped when no credentials are configured.

Test plan

  • compileJava and compileTestJava pass with Log4j 1.x off compileClasspath
  • org.openrewrite.java.logging.log4j.* tests pass, 26 tests including the setLevel case in Log4j1ToLog4j2Test
  • Build resolves the plugin classpath from CGP with no init script
  • Next vulnerability scan no longer reports log4j:log4j against this repo

@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Sep 1, 2026
This was referenced Sep 2, 2026
This was referenced Sep 2, 2026
@kmccarp
kmccarp merged commit 4533f42 into main Sep 2, 2026
1 check passed
@kmccarp
kmccarp deleted the log4j1-imperative branch September 2, 2026 11:58
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants