Repository navigation
Conversation
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
This reverts commit 8801336.
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
There was a problem hiding this comment.
Risk: low.
Automated risk review (dry run): Low
This PR would be automatically approved.
Why: It adds optional protocolFallbackTTL parsing on FDv2 Goodbye and pass-through in FDv2ProtocolHandler, with tests for absent, numeric, and malformed values. There are no infrastructure, auth, or approval-policy changes.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver
| return Duration.ofMillis((long) (reader.nextDouble() * 1000)); | ||
| } | ||
| reader.skipValue(); | ||
| return Duration.ZERO; |
There was a problem hiding this comment.
Hmm, is it actually safe to treat missing or incorrect-type values as 0? Are they always treated the same?
There was a problem hiding this comment.
A missing field isn't mapped to 0. It stays null, which means "no directive". Only a field that is present but not a number becomes ZERO.
For a field that is present, the spec handles wrong-type and 0 the same way: 1.6.1.4 says a malformed TTL uses the default, and 1.6.1.5 says 0, negative, and >1h also use the default. Both get the jittered 1h default.
Still, ZERO is a sentinel, so this only works if every consumer knows it means "default". If you'd prefer something less implicit, I see two options:
- Keep the raw value (
LDValue), as rust-server-sdk does withOption<serde_json::Value>, and let the server SDK interpret it. - Apply the
(0, 1h]check here and returnnullfor absent, a validDurationfor in range, and a single documented "use default" value otherwise.
Do you want me to switch to one of those?
| reason = reader.nextString(); | ||
| break; | ||
| case "protocolFallbackTTL": | ||
| if (reader.peek() == JsonToken.NULL) { |
There was a problem hiding this comment.
It's kinda strange to special-case null here, when the adapter already handles other non-number cases differently.
There was a problem hiding this comment.
I special-cased JSON null to match two things. Gson's @JsonAdapter is null-safe by default, so Gson deserialization already reads null as absent. And rust-server-sdk treats null as absent, because serde reads a JSON null into Option as None.
The spec only talks about the field's "presence", though. If we count "protocolFallbackTTL": null as present, it becomes a directive with the default TTL, parse() just calls the adapter, and the special case goes away. Rust and the Gson path would then differ from this on null, but only Gson round-trip tests use the Gson path.
Should I drop the special case?


Parses the optional
protocolFallbackTTLfield of the FDv2goodbyepayload inlaunchdarkly-java-sdk-internal, so the server SDK can treat it as an FDv1 fallback directive.Part of SDK-2987.
Goodbye.getProtocolFallbackTTL()andFDv2ActionGoodbye.getProtocolFallbackTTL()return a nullableDuration:nullwhen the field is absent or JSONnull, the value in seconds when it is a number, andDuration.ZEROwhen it is present but not a number.Duration.ZEROworks as "use the default TTL", because the spec already treats 0 that way (DATASYSTEM 1.6.1.3–1.6.1.5). A malformed TTL still counts as a directive.Implementation details
TypeAdapteronGoodbye.protocolFallbackTTLis needed because existing tests round-tripGoodbyethrough Gson, and Gson can't reflect intojava.time.Durationon JDK 17.parse()reuses the adapter's read logic.ZERO) and JSONnull(→ absent), plus pass-through inFDv2ProtocolHandler../gradlew test checkstyleMain checkstyleTestinlib/shared/internal.Link to Devin session: https://app.devin.ai/sessions/cce64c67519f4babaa75176c06961c5e
Open in Devin Desktop: https://app.devin.ai/desktop/session/cce64c67519f4babaa75176c06961c5e?variant=devin
Requested by: @beekld
Note
Overview
Adds optional
protocolFallbackTTLto the FDv2goodbyepayload and threads it through the protocol handler so callers can react when the server signals an FDv1-style fallback.Goodbyenow stores a nullableDuration, parsesprotocolFallbackTTLfrom JSON (numeric seconds, including fractions), and round-trips it via a GsonTypeAdapterbecause JDK 17 cannot reflectDuration. Malformed or non-numeric values becomeDuration.ZERO(meaning “use default TTL” per spec); absent field or JSONnullstaysnull.FDv2ActionGoodbyeexposes the same value, and goodbye handling passes it through from the payload.Tests cover parsing edge cases and handler pass-through; existing one-arg constructors remain for backward compatibility. Clamping and jitter are intentionally left for a later server SDK change.
Reviewed by Cursor Bugbot for commit 6502a0d. Bugbot is set up for automated code reviews on this repo. Configure here.