Skip to content

Adopt jspecify + NullAway null-checking on fdb-record-layer-debugger - #4580

Draft
arnaud-lacurie wants to merge 1 commit into
apple/arnaud-lacurie/jspecify-nullaway/extensionsfrom
apple/arnaud-lacurie/jspecify-nullaway/debugger
Draft

Adopt jspecify + NullAway null-checking on fdb-record-layer-debugger#4580
arnaud-lacurie wants to merge 1 commit into
apple/arnaud-lacurie/jspecify-nullaway/extensionsfrom
apple/arnaud-lacurie/jspecify-nullaway/debugger

Conversation

@arnaud-lacurie

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

Copy link
Copy Markdown
Collaborator

7th of a 14-PR stack adopting jspecify + NullAway null-checking, stacked on #4579 (fdb-extensions). Same treatment applied to fdb-record-layer-debugger. See inline comments for specific findings.

final PlannerPhase plannerPhase = getPlannerPhase();
plannerRepl.printKeyValue("plannerPhase",
(getPlannerPhase() == null ? getPlannerPhase().name() : "any").toLowerCase(Locale.ROOT));
(plannerPhase == null ? "any" : plannerPhase.name()).toLowerCase(Locale.ROOT));

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 bug fixed here: the previous ternary was (getPlannerPhase() == null ? getPlannerPhase().name() : "any") — backwards on both sides. When the phase was null it called .name() on the null value (guaranteed NullPointerException), and when it was non-null it printed the literal string "any" instead of the actual phase name, so OnPhaseBreakPoint.onList() never displayed the real planner phase. The fix captures getPlannerPhase() once into a local and corrects the ternary to (plannerPhase == null ? "any" : plannerPhase.name()), matching what the null-check should have guarded in the first place.

Same treatment as the grpc/jdbc branches: jspecify + NullAway wired via
net.ltgt.errorprone, scoped to this module only; the
com.apple.foundationdb.record.query.plan.cascades.debug package is marked
@NullMarked; javax.annotation.Nonnull/Nullable usages replaced with jspecify's
@nullable.

Compiling with NullAway surfaced a real bug in PlannerRepl.OnPhaseBreakPoint:
onList() had its null-check ternary backwards
(getPlannerPhase() == null ? getPlannerPhase().name() : "any"), which would
NPE whenever "break list" was run after setting a phase-less "phase"
breakpoint; fixed the logic (and a similar hashCode() case flagged by
SpotBugs) using a local variable instead of re-invoking the getter.

Debugger.setDebugger(null) (fdb-record-layer-core, outside this module)
documents and implements null-acceptance to clear the debugger, but its
parameter isn't annotated @nullable; suppressed at the two call sites in this
module's tests with a comment, since fixing the declaration is out of scope.
@arnaud-lacurie
arnaud-lacurie force-pushed the apple/arnaud-lacurie/jspecify-nullaway/debugger branch from 9605a6c to 65fe185 Compare September 8, 2026 00:07
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