From 53bc93beb0fb298dba566505fd22a3fcf3a8c601 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 5 Aug 2026 00:12:54 +0200 Subject: [PATCH] Make subpackage recursion explicit where these renames depend on it Both of these `ChangePackage` rules omit `recursive` while depending on it to move types out of subpackages of `oldPackageName`. `org.apache.commons.math` -> `org.apache.commons.math3` has to carry `org.apache.commons.math.stat.StatUtils` along with it. The httpclient rule is step 2 of a three-step chain: org.apache.http.entity -> org.apache.hc.core5.http.io.entity (recursive: true) org.apache.hc.core5.http.io.entity.mime -> org.apache.hc.client5.http.entity.mime org.apache.hc.client5.http.entity.mime.content -> org.apache.hc.client5.http.entity.mime Step 1 relocates `org.apache.http.entity.mime.content.StringBody` under `core5`, step 2 has to move the whole `mime` subtree over to `client5`, and step 3 flattens `.content`. Step 2 only reaches `.content.StringBody` by recursing, so without it the chain stalls at `org.apache.hc.core5.http.io.entity.mime.content.StringBody`, a package that does not exist in httpclient5. Relying on the default here was always fragile: `ChangePackage.recursive` is `@Nullable` with no documented default, and a null was read as non-recursive by the recipe's preconditions but as recursive by its visitor, so subpackage renames only happened for files that also referenced a type sitting directly in `oldPackageName`. openrewrite/rewrite#8382 settles null as non-recursive, which makes that latent dependency visible. Stating `recursive: true` is correct either way and is green both with and without that change. --- src/main/resources/META-INF/rewrite/apache-commons-math-2-3.yml | 1 + src/main/resources/META-INF/rewrite/apache-httpclient-5.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/META-INF/rewrite/apache-commons-math-2-3.yml b/src/main/resources/META-INF/rewrite/apache-commons-math-2-3.yml index 86a2159..d474798 100644 --- a/src/main/resources/META-INF/rewrite/apache-commons-math-2-3.yml +++ b/src/main/resources/META-INF/rewrite/apache-commons-math-2-3.yml @@ -44,3 +44,4 @@ recipeList: - org.openrewrite.java.ChangePackage: oldPackageName: org.apache.commons.math newPackageName: org.apache.commons.math3 + recursive: true diff --git a/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml b/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml index 71c6356..351e492 100644 --- a/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml +++ b/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml @@ -413,6 +413,7 @@ recipeList: - org.openrewrite.java.ChangePackage: oldPackageName: org.apache.hc.core5.http.io.entity.mime newPackageName: org.apache.hc.client5.http.entity.mime + recursive: true - org.openrewrite.java.ChangePackage: oldPackageName: org.apache.hc.client5.http.entity.mime.content newPackageName: org.apache.hc.client5.http.entity.mime