Skip to content

Commit 20b8fff

Browse files
kmccarptimtebeek
andauthored
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 <[email protected]>
1 parent dd7ec21 commit 20b8fff

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/resources/META-INF/rewrite/jspecify.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ recipeList:
2626
- org.openrewrite.java.jspecify.MigrateFromJavaxAnnotationApi
2727
- org.openrewrite.java.jspecify.MigrateFromJakartaAnnotationApi
2828
- org.openrewrite.java.jspecify.MigrateFromJetbrainsAnnotations
29-
- org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations
29+
# Running the following recipe on current versions of Spring can cause Spring to misunderstand a nullable field.
30+
# For instance, a custom Prometheus scrape endpoint with @Nullable Set<String> includedNames will fail if
31+
# includedNames is null and if @Nullable is @org.jspecify.annotations.Nullable.
32+
# - org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations
3033

3134
---
3235
type: specs.openrewrite.org/v1beta/recipe

src/test/java/org/openrewrite/java/migrate/jspecify/MigrateToJspecifyTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.DocumentExample;
20+
import org.openrewrite.Issue;
2021
import org.openrewrite.java.JavaParser;
2122
import org.openrewrite.test.RecipeSpec;
2223
import org.openrewrite.test.RewriteTest;
@@ -324,9 +325,13 @@ class Bar {
324325
);
325326
}
326327

328+
@Issue("https://github.com/openrewrite/rewrite-migrate-java/pull/602")
327329
@Test
328330
void migrateFromSpringFrameworkAnnotationsToJspecify() {
329331
rewriteRun(
332+
spec -> spec.recipeFromResource(
333+
"/META-INF/rewrite/jspecify.yml",
334+
"org.openrewrite.java.jspecify.MigrateFromSpringFrameworkAnnotations"),
330335
mavenProject("foo",
331336
//language=java
332337
srcMainJava(

0 commit comments

Comments
 (0)