Skip to content

Commit b503ad3

Browse files
committed
Add nullability annotations to tests in module/spring-boot-jdbc-test
See gh-47263
1 parent a350ead commit b503ad3

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

module/spring-boot-jdbc-test/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ dependencies {
5151
testRuntimeOnly("com.h2database:h2")
5252
testRuntimeOnly("org.hsqldb:hsqldb")
5353
}
54+
55+
tasks.named("compileTestJava") {
56+
options.nullability.checking = "tests"
57+
}
58+
59+
tasks.named("compileDockerTestJava") {
60+
options.nullability.checking = "tests"
61+
}

module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.jdbc.test.autoconfigure;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
/**
2022
* Example entity used with {@link JdbcTest @JdbcTest} tests.
2123
*
@@ -25,9 +27,9 @@ public class ExampleEntity {
2527

2628
private final int id;
2729

28-
private String name;
30+
private @Nullable String name;
2931

30-
public ExampleEntity(int id, String name) {
32+
public ExampleEntity(int id, @Nullable String name) {
3133
this.id = id;
3234
this.name = name;
3335
}
@@ -40,11 +42,11 @@ public int getId() {
4042
return this.id;
4143
}
4244

43-
public String getName() {
45+
public @Nullable String getName() {
4446
return this.name;
4547
}
4648

47-
public void setName(String name) {
49+
public void setName(@Nullable String name) {
4850
this.name = name;
4951
}
5052

0 commit comments

Comments
 (0)