Skip to content

fix: Reconnect the FDv2 stream after a restart that follows an earlier disconnect - #233

Merged
tanderson-ld merged 1 commit into
mainfrom
rlamb/fdv2-stream-restart-after-disconnect
Oct 14, 2026
Merged

tanderson-ld merged 1 commit into
mainfrom
rlamb/fdv2-stream-restart-after-disconnect

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

The FDv2 streaming synchronizer restarts its stream with interrupt() after a goodbye, invalid data, or a protocol error. If the stream had disconnected at any earlier time, okhttp-eventsource reports that interrupt() as a StreamClosedByCallerException fault. handleError treated every such fault as a shutdown, so the synchronizer thread exited. The stream did not reconnect, and the data system got no further results.

Now handleError stops only when close() was called. After a restart it continues to read, and the event source reconnects. The restart already queued its result and recorded the stream init, so the fault does not add either one again.

New tests in StreamingSynchronizerImplTest cover a goodbye and invalid data after an earlier disconnect. They also cover close() after an earlier disconnect, both during a restart and without one.


Note

Overview
Fixes FDv2 streaming stopping permanently when a deliberate restartStream() (goodbye, invalid data, etc.) follows an earlier disconnect. OkHttp EventSource surfaces interrupt() as StreamClosedByCallerException, and handleError used to treat every such fault as shutdown and exit the read loop.

handleError now stops the stream only when close() set closed under closeLock. After a restart-induced caller close it returns true so the thread keeps consuming events and reconnects, without duplicating queued results or stream-init diagnostics already handled by restartStream(). Real failures still call recordStreamInit(true) on the non–caller-close path.

Adds integration tests for goodbye and invalid data after a prior disconnect, plus close() during/after reconnect so no extra HTTP connections are made.

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

…r disconnect

The FDv2 streaming synchronizer restarts its stream with interrupt() on a
goodbye, invalid data, or a protocol error. After any earlier disconnect,
okhttp-eventsource 5.0.0 reports that interrupt() as a
StreamClosedByCallerException fault before it reconnects. The synchronizer
treated every such fault as a shutdown and stopped reading, so the stream
stopped with no result for the data system.

Now the synchronizer stops only when close() was called. For a restart it
continues to read, and the event source reconnects. The restart already
queued its result and recorded the stream init, so the fault adds neither.
@kinyoklion
kinyoklion marked this pull request as ready for review October 13, 2026 20:42
@kinyoklion
kinyoklion requested a review from a team as a code owner October 13, 2026 20:42
@tanderson-ld
tanderson-ld merged commit 3c69b44 into main Oct 14, 2026
26 checks passed
@tanderson-ld
tanderson-ld deleted the rlamb/fdv2-stream-restart-after-disconnect branch October 14, 2026 14:13
kinyoklion pushed a commit that referenced this pull request Oct 14, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.17.3](launchdarkly-java-server-sdk-7.17.2...launchdarkly-java-server-sdk-7.17.3)
(2026-10-14)


### Bug Fixes

* Open a new connection on each stream reconnect
([#232](#232))
([770f0a9](770f0a9))
* Reconnect the FDv2 stream after a restart that follows an earlier
disconnect
([#233](#233))
([3c69b44](3c69b44))

---
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 7.17.3** for `lib/sdk/server`: bumps the published SDK
version everywhere Release Please tracks
(`.release-please-manifest.json`, `gradle.properties`, and
`Version.SDK_VERSION`) from **7.17.2** to **7.17.3**.
> 
> The new **CHANGELOG** entry documents two **bug fixes** already landed
on main: opening a **fresh connection on each stream reconnect**, and
ensuring the **FDv2 stream reconnects** after a restart that follows an
earlier disconnect. This PR does not contain those code changes—only the
version and release notes.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6938932. 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants