From 20b8fffb0ea48ba279d12cca2e1d3a3d23d30419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Carpenter=E2=84=A2=EF=B8=8F?= Date: Wed, 13 Nov 2024 13:08:06 -0300 Subject: [PATCH] Prevent breakage of usages of Spring's @Nullable (#602) * Prevent breakage of usages of Spring's @Nullable * Update jspecify.yml * Fix test by being more specific about the recipe it runs --------- Co-authored-by: Tim te Beek --- src/main/resources/META-INF/rewrite/jspecify.yml | 5 ++++- .../java/migrate/jspecify/MigrateToJspecifyTest.java | 5 +++++ 2 files changed, 9 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..020c4551f 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.annotations.Nullable. + # - org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations --- type: specs.openrewrite.org/v1beta/recipe 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(