Skip to content

feat: Parse protocolFallbackTTL from FDv2 goodbye - #265

Merged
beekld merged 5 commits into
mainfrom
devin/1794878452-goodbye-fallback-ttl
Nov 18, 2026
Merged

beekld merged 5 commits into
mainfrom
devin/1794878452-goodbye-fallback-ttl

Conversation

@beekld

@beekld beekld commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Parses the optional protocolFallbackTTL field of the FDv2 goodbye payload in launchdarkly-java-sdk-internal, so the server SDK can treat it as an FDv1 fallback directive.

Part of SDK-2987.

  • Goodbye.getProtocolFallbackTTL() and FDv2ActionGoodbye.getProtocolFallbackTTL() return a nullable Duration: null when the field is absent or JSON null, the value in seconds when it is a number, and Duration.ZERO when it is present but not a number.
  • Duration.ZERO works 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.
  • Out-of-range clamping and jitter are deliberately left out of this library. The server SDK will apply them in a follow-up PR after this is released.
  • The one-arg constructors are kept, so existing callers still compile.
Implementation details
  • A field-level Gson TypeAdapter on Goodbye.protocolFallbackTTL is needed because existing tests round-trip Goodbye through Gson, and Gson can't reflect into java.time.Duration on JDK 17. parse() reuses the adapter's read logic.
  • Tests cover absent, integer, fractional, 0, negative, >3600, string/bool/object/array (→ ZERO) and JSON null (→ absent), plus pass-through in FDv2ProtocolHandler.
  • Ran ./gradlew test checkstyleMain checkstyleTest in lib/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 protocolFallbackTTL to the FDv2 Goodbye payload and threads it through FDv2ProtocolHandler.FDv2ActionGoodbye, so callers can read a server-directed FDv1 fallback delay on disconnect.

Parsing treats absent or JSON null as null, numeric values as seconds (fractional supported), and non-numbers as Duration.ZERO (spec: use default TTL). A custom Gson FallbackTTLAdapter handles round-trip serialization for Duration on JDK 17. One-arg constructors remain for backward compatibility.

Tests cover TTL edge cases in Goodbye.parse and pass-through from handleEvent.

Reviewed by Cursor Bugbot for commit b7d1577. Bugbot is set up for automated code reviews on this repo. Configure here.

devin-ai-integration Bot and others added 4 commits November 17, 2026 01:22
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
@beekld
beekld requested a review from a team as a code owner November 17, 2026 01:24
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@cursor cursor Bot added the risk:low label Nov 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
@beekld
beekld merged commit 72d0fe1 into main Nov 18, 2026
31 checks passed
@beekld
beekld deleted the devin/1794878452-goodbye-fallback-ttl branch November 18, 2026 21:44
kinyoklion pushed a commit that referenced this pull request Nov 18, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.13.0](launchdarkly-java-sdk-internal-1.12.2...launchdarkly-java-sdk-internal-1.13.0)
(2026-11-18)


### Features

* Parse protocolFallbackTTL from FDv2 goodbye
([#265](#265))
([72d0fe1](72d0fe1))


### Bug Fixes

* Clear empty FDv2 selectors in shared protocol handling
([#261](#261))
([576b081](576b081))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release Please** cuts **`lib/shared/internal`** from **1.12.2** to
**1.13.0**, updating `.release-please-manifest.json`,
`gradle.properties`, and `CHANGELOG.md` only.
> 
> The published **1.13.0** notes add **FDv2 goodbye** support for
parsing **`protocolFallbackTTL`** (including malformed/null handling via
`Goodbye`) and a fix to **clear empty FDv2 selectors** in shared
protocol handling so empty selector state does not linger incorrectly.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4ca3c46. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kinyoklion added a commit that referenced this pull request Nov 19, 2026
**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [ ] I have validated my changes against all supported platform
versions

**Related issues**

Follow-up to #265. Android consumes this library
(android-client-sdk#435); `java.time.Duration` is only available
natively on API 26+, and Android supports API 21 without core-library
desugaring.

**Describe the solution you've provided**

`Goodbye` and `FDv2ProtocolHandler` in `lib/shared/internal` now store
`protocolFallbackTTL` as a nullable `Long` of milliseconds instead of a
`Duration`. The wire format (seconds) is unchanged.

Internal API changes:
- `Goodbye.getProtocolFallbackTTL()` (returned `Duration`) is replaced
by `getProtocolFallbackTTLMillis()` (returns `Long`).
- The two-argument constructors take a `Long` of milliseconds; the
one-argument constructors are unchanged.

Neither the Java server SDK nor the Android SDK calls the old getter.
The compiled production classes in the module have no `java.time`
references.

**Describe alternatives you've considered**

Keeping the `Duration` getter alongside a millis accessor. That still
leaves `Duration` in the parse path, which is what runs on Android.

**Additional context**

Ran `FDv2PayloadsTest` and `FDv2ProtocolHandlerTest` plus the rest of
the module's JUnit tests directly: 324 passing. Local Gradle/Checkstyle
was blocked by Maven Central rate limiting, so CI is the check for
those.

Link to Devin session:
https://app.devin.ai/sessions/2540f086f1ea4dfba1470051465fb0fd
Open in Devin Desktop:
https://app.devin.ai/desktop/session/2540f086f1ea4dfba1470051465fb0fd?variant=devin
Requested by: @kinyoklion

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> FDv2 **goodbye** handling no longer uses `java.time.Duration` for
`protocolFallbackTTL`. **`Goodbye`** and
**`FDv2ProtocolHandler.FDv2ActionGoodbye`** now hold a nullable **`Long`
in milliseconds**, with wire JSON still expressed in **seconds** via the
existing `FallbackTTLAdapter` (malformed values still map to **0**).
> 
> The public internal API rename is **`getProtocolFallbackTTL()` →
`getProtocolFallbackTTLMillis()`**, and constructors that took a
`Duration` take millis instead. Tests in **`FDv2PayloadsTest`** and
**`FDv2ProtocolHandlerTest`** expect millis values and add coverage that
Gson serializes TTL back to seconds (e.g. 1250 ms → `1.25`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1f5fe34. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants