Skip to content

Commit

Permalink
Prevent breakage of usages of Spring's @nullable (#602)
Browse files Browse the repository at this point in the history
* 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 <tim@moderne.io>
  • Loading branch information
kmccarp and timtebeek authored Nov 13, 2024
1 parent dd7ec21 commit 20b8fff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/resources/META-INF/rewrite/jspecify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 20b8fff

Please sign in to comment.