Skip to content

Make subpackage recursion explicit in the Micronaut LDAP rename - #144

Merged
timtebeek merged 1 commit into
mainfrom
tim/changepackage-recursive-subpackages
Aug 5, 2026
Merged

Make subpackage recursion explicit in the Micronaut LDAP rename#144
timtebeek merged 1 commit into
mainfrom
tim/changepackage-recursive-subpackages

Conversation

@timtebeek

@timtebeek timtebeek commented Aug 5, 2026

Copy link
Copy Markdown
Member

io.micronaut.configuration.security.ldapio.micronaut.security.ldap in micronaut2-to-3.yml omits recursive while depending on it, so types in its subpackages were never migrated.

Verified against the published artifacts — micronaut-security-ldap 1.4.0 → 4.13.0:

old new
io.micronaut.configuration.security.ldap.configuration io.micronaut.security.ldap.configuration
io.micronaut.configuration.security.ldap.context io.micronaut.security.ldap.context
io.micronaut.configuration.security.ldap.group io.micronaut.security.ldap.group

All three map exactly under prefix substitution, so recursion is both safe and required here.

The sibling io.micronaut.configuration.cassandraio.micronaut.cassandra rule is deliberately left alone: that package has no subpackages in micronaut-cassandra 1.2.0. (The io.micronaut.cassandra.health package in current versions was added later, so it isn't a migration concern.)

These renames had no test coverage at all, so the new Micronaut2to3PackageMigrationTest covers both the direct type and the subpackage type.

Why the tests didn't catch this

ChangePackage.recursive is @Nullable with required = false and no documented default, and a null was read two different ways inside the same recipe: non-recursive by its preconditions, recursive by its visitor. The upshot is that a subpackage type gets renamed only if the file also references a type sitting directly in oldPackageName — which every existing fixture happens to do. A real source file importing only the subpackage type was never migrated.

Verification

  • Full ./gradlew test green. Each new test fails without the recursive: true line and passes with it. Correct on its own merits and safe to merge now, independently of rewrite#8382.

`io.micronaut.configuration.security.ldap` -> `io.micronaut.security.ldap`
omits `recursive` while depending on it, so types in its subpackages were
never migrated.

Verified against the published artifacts:

    micronaut-security-ldap 1.4.0                        -> 4.13.0
      io.micronaut.configuration.security.ldap.configuration -> io.micronaut.security.ldap.configuration
      io.micronaut.configuration.security.ldap.context       -> io.micronaut.security.ldap.context
      io.micronaut.configuration.security.ldap.group         -> io.micronaut.security.ldap.group

All three map exactly under prefix substitution, so recursion is both safe
and required here. The sibling `io.micronaut.configuration.cassandra` rule is
left alone: that package has no subpackages in micronaut-cassandra 1.2.0.

This had no test coverage at all. `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 a subpackage type
was renamed only for files that also referenced a type sitting directly in
`oldPackageName`. The new test covers both the direct and the subpackage type;
the subpackage case fails without this change.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Aug 5, 2026
@timtebeek
timtebeek merged commit efa246f into main Aug 5, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/changepackage-recursive-subpackages branch August 5, 2026 09:09
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 5, 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.

1 participant