Skip to content

Adopt jspecify + NullAway null-checking on fdb-test-utils - #4577

Draft
arnaud-lacurie wants to merge 1 commit into
apple/arnaud-lacurie/jspecify-nullaway/java-annotationsfrom
apple/arnaud-lacurie/jspecify-nullaway/test-utils
Draft

Adopt jspecify + NullAway null-checking on fdb-test-utils#4577
arnaud-lacurie wants to merge 1 commit into
apple/arnaud-lacurie/jspecify-nullaway/java-annotationsfrom
apple/arnaud-lacurie/jspecify-nullaway/test-utils

Conversation

@arnaud-lacurie

@arnaud-lacurie arnaud-lacurie commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

4th of a 14-PR stack adopting jspecify + NullAway null-checking, stacked on #4576 (fdb-java-annotations). Same treatment applied to fdb-test-utils. See inline comments for specific findings.

Wires jspecify + NullAway (via net.ltgt.errorprone) scoped to this module only;
both of its unrelated top-level packages (com.apple.foundationdb.test and
com.apple.test) are marked @NullMarked and listed in AnnotatedPackages.
javax.annotation.Nonnull/Nullable usages replaced with jspecify's @nullable.

Compiling with NullAway surfaced a genuine gap: FDBTestEnvironment's
clusterFiles list can contain a null entry (meaning "use the default cluster
file" when FDB_ENVIRONMENT_YAML is unset), but allClusterFiles(),
allClusterFilesInRandomOrder(), and randomClusterFile() were typed as if
non-null; now typed List<@nullable String> / @nullable String to match actual
behavior. Also hardened parseFDBEnvironmentYaml() to fail fast with a clear
IllegalStateException if "clusterFiles" is missing from the yaml, rather than
returning null silently.
}

@Nullable
public static String randomClusterFile() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real finding: randomClusterFile() was previously declared to return plain String even though clusterFiles can contain a null entry (the "no fdb-environment.yaml configured" case uses Collections.singletonList(null)), and every other accessor here (getClusterFile(int), and now allClusterFiles()/allClusterFilesInRandomOrder()) already exposed that nullability. So callers of randomClusterFile() (e.g. TestDatabaseExtension.getDatabase()) had no static signal that a null cluster file could come back. Adding @Nullable here, plus widening the backing list to List<@Nullable String>, documents a contract that was previously only true by accident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build improvement Improvement to the build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant