From b652150c9906787f391a4529316b87169edb5fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Carpenter=E2=84=A2=EF=B8=8F?= Date: Wed, 13 Nov 2024 12:48:25 -0300 Subject: [PATCH 1/3] Prevent breakage of usages of Spring's @Nullable --- src/main/resources/META-INF/rewrite/jspecify.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/rewrite/jspecify.yml b/src/main/resources/META-INF/rewrite/jspecify.yml index efa7a10c0..1ffe5acf8 100644 --- a/src/main/resources/META-INF/rewrite/jspecify.yml +++ b/src/main/resources/META-INF/rewrite/jspecify.yml @@ -26,7 +26,10 @@ recipeList: - org.openrewrite.java.jspecify.MigrateFromJavaxAnnotationApi - org.openrewrite.java.jspecify.MigrateFromJakartaAnnotationApi - org.openrewrite.java.jspecify.MigrateFromJetbrainsAnnotations - - org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations + # Running the following recipe on current versions of Spring can cause Spring to misunderstand a nullable field. + # For instance, a custom Prometheus scrape endpoint with @Nullable Set includedNames will fail if + # includedNames is null and if @Nullable is @org.jspecify.Nullable. + # - org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations --- type: specs.openrewrite.org/v1beta/recipe From 40347190170c61f467456e9fa8704926395d21e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Carpenter=E2=84=A2=EF=B8=8F?= Date: Wed, 13 Nov 2024 12:52:12 -0300 Subject: [PATCH 2/3] Update jspecify.yml --- src/main/resources/META-INF/rewrite/jspecify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/rewrite/jspecify.yml b/src/main/resources/META-INF/rewrite/jspecify.yml index 1ffe5acf8..020c4551f 100644 --- a/src/main/resources/META-INF/rewrite/jspecify.yml +++ b/src/main/resources/META-INF/rewrite/jspecify.yml @@ -28,7 +28,7 @@ recipeList: - org.openrewrite.java.jspecify.MigrateFromJetbrainsAnnotations # Running the following recipe on current versions of Spring can cause Spring to misunderstand a nullable field. # For instance, a custom Prometheus scrape endpoint with @Nullable Set includedNames will fail if - # includedNames is null and if @Nullable is @org.jspecify.Nullable. + # includedNames is null and if @Nullable is @org.jspecify.annotations.Nullable. # - org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations --- From 428af12aabc6039bedef5529ebc1dcf5020cffea Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 13 Nov 2024 17:07:53 +0100 Subject: [PATCH 3/3] Fix test by being more specific about the recipe it runs --- .../java/migrate/jspecify/MigrateToJspecifyTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/org/openrewrite/java/migrate/jspecify/MigrateToJspecifyTest.java b/src/test/java/org/openrewrite/java/migrate/jspecify/MigrateToJspecifyTest.java index 51c7d0bc3..4b094becd 100644 --- a/src/test/java/org/openrewrite/java/migrate/jspecify/MigrateToJspecifyTest.java +++ b/src/test/java/org/openrewrite/java/migrate/jspecify/MigrateToJspecifyTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; import org.openrewrite.DocumentExample; +import org.openrewrite.Issue; import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -324,9 +325,13 @@ class Bar { ); } + @Issue("https://github.com/openrewrite/rewrite-migrate-java/pull/602") @Test void migrateFromSpringFrameworkAnnotationsToJspecify() { rewriteRun( + spec -> spec.recipeFromResource( + "/META-INF/rewrite/jspecify.yml", + "org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations"), mavenProject("foo", //language=java srcMainJava(