Skip to content

Commit aa2cf03

Browse files
authored
Add JSpecify and NullAway (#27)
1 parent c2df07e commit aa2cf03

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<artifactId>jimfs</artifactId>
5959
<version>${jimfs.version}</version>
6060
</dependency>
61+
<dependency>
62+
<groupId>org.jspecify</groupId>
63+
<artifactId>jspecify</artifactId>
64+
<version>1.0.0</version>
65+
</dependency>
6166
<!-- Provided -->
6267
<dependency>
6368
<groupId>org.junit.jupiter</groupId>
@@ -107,6 +112,7 @@
107112
-Xplugin:ErrorProne
108113
-Xep:ImmutableEnumChecker:OFF
109114
-Xep:SameNameButDifferent:OFF
115+
-XepOpt:NullAway:OnlyNullMarked
110116
</compilerArg>
111117
</compilerArgs>
112118
<annotationProcessorPaths>
@@ -115,6 +121,11 @@
115121
<artifactId>error_prone_core</artifactId>
116122
<version>2.38.0</version>
117123
</path>
124+
<path>
125+
<groupId>com.uber.nullaway</groupId>
126+
<artifactId>nullaway</artifactId>
127+
<version>0.12.7</version>
128+
</path>
118129
</annotationProcessorPaths>
119130
<failOnWarning>true</failOnWarning>
120131
</configuration>
@@ -129,9 +140,11 @@
129140
<artifactId>maven-javadoc-plugin</artifactId>
130141
<version>3.11.2</version>
131142
<configuration>
143+
<additionalOptions>--link-modularity-mismatch=info</additionalOptions> <!-- https://github.com/jspecify/jspecify/issues/712 -->
132144
<failOnWarnings>true</failOnWarnings>
133145
<links>
134146
<link>https://javadoc.io/static/com.google.jimfs/jimfs/${jimfs.version}/</link>
147+
<link>https://jspecify.dev/docs/api/</link>
135148
<link>https://junit.org/junit5/docs/${junit-jupiter.version}/api/</link>
136149
</links>
137150
<release>9</release>
@@ -229,6 +242,7 @@
229242
<excludes>
230243
<exclude>module-info.java</exclude>
231244
</excludes>
245+
<failOnWarning>false</failOnWarning> <!-- https://github.com/jspecify/jspecify/issues/302 -->
232246
</configuration>
233247
</execution>
234248
</executions>

src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Locale;
2525
import java.util.Optional;
2626
import java.util.function.Supplier;
27+
import org.jspecify.annotations.Nullable;
2728
import org.junit.jupiter.api.extension.AnnotatedElementContext;
2829
import org.junit.jupiter.api.extension.ExtensionContext;
2930
import org.junit.jupiter.api.io.TempDirFactory;
@@ -59,7 +60,7 @@ public final class JimfsTempDirFactory implements TempDirFactory {
5960

6061
private static final String DEFAULT_PREFIX = "junit-";
6162

62-
private FileSystem fileSystem;
63+
private @Nullable FileSystem fileSystem;
6364

6465
/** Create a new {@code JimfsTempDirFactory} instance. */
6566
public JimfsTempDirFactory() {}
@@ -102,6 +103,9 @@ private static boolean isNotDefaultConfiguration(JimfsTempDir.Configuration valu
102103
/** {@inheritDoc} */
103104
@Override
104105
public void close() throws IOException {
105-
fileSystem.close();
106+
if (fileSystem != null) {
107+
fileSystem.close();
108+
fileSystem = null;
109+
}
106110
}
107111
}

src/main/java/io/github/scordio/jimfs/junit/jupiter/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@
1818
* JUnit Jupiter {@link org.junit.jupiter.api.io.TempDir} extension based on {@link
1919
* com.google.common.jimfs.Jimfs}.
2020
*/
21+
@NullMarked
2122
package io.github.scordio.jimfs.junit.jupiter;
23+
24+
import org.jspecify.annotations.NullMarked;

src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
2222
module io.github.scordio.jimfs.junit.jupiter {
23+
requires static org.jspecify;
2324
requires transitive com.google.common.jimfs;
2425
requires org.junit.jupiter.api;
2526

0 commit comments

Comments
 (0)