diff --git a/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java b/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java index 0cfa112df..30e5a51fb 100644 --- a/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java +++ b/src/main/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapter.java @@ -53,7 +53,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex J.Identifier ident = new J.Identifier(Tree.randomId(), Space.format(" "), Markers.EMPTY, emptyList(), "SmartInstantiationAwareBeanPostProcessor", JavaType.buildType(toImplementsFqn), null); J.Block body = cd.getBody(); - cd = maybeAutoFormat(cd, cd.withBody(cd.getBody().withStatements(emptyList())).withImplements(ListUtils.concat(cd.getImplements(), ident)), ctx, getCursor()); + cd = maybeAutoFormat(cd, cd.withBody(cd.getBody().withStatements(emptyList())).withImplements(ListUtils.concat(cd.getImplements(), ident)), ctx, getCursor().getParentOrThrow()); cd = cd.withBody(body); } return cd; diff --git a/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java b/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java index ecd1a8dcd..80af241d3 100644 --- a/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java +++ b/src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/framework/MigrateInstantiationAwareBeanPostProcessorAdapterTest.java @@ -39,13 +39,13 @@ void migrateInterface() { java( """ import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; - + class A extends InstantiationAwareBeanPostProcessorAdapter { } """, """ import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor; - + class A implements SmartInstantiationAwareBeanPostProcessor { } """