fix: harden Horizon SSE stream handling#791
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors Horizon SSE streaming to use OkHttp’s public EventSources factory instead of the internal RealEventSource, reducing reliance on OkHttp internal APIs.
Changes:
- Remove
okhttp3.internal.sse.RealEventSourceusage/import. - Create SSE streams via
EventSources.createFactory(okHttpClient).newEventSource(...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #791 +/- ##
============================================
+ Coverage 81.42% 83.01% +1.58%
- Complexity 1473 1488 +15
============================================
Files 220 220
Lines 5530 5529 -1
Branches 568 568
============================================
+ Hits 4503 4590 +87
+ Misses 717 616 -101
- Partials 310 323 +13
🚀 New features to boost your workflow:
|
- use OkHttp's public SSE factory instead of the internal RealEventSource - add more test cases
22b5257 to
9e8b3a9
Compare
RealEventSourceThere was a problem hiding this comment.
Pull request overview
This PR refactors Horizon SSE streaming to use OkHttp’s public SSE API (EventSources) instead of relying on OkHttp’s internal RealEventSource, and adds focused tests to validate streaming, reconnect, and failure behaviors.
Changes:
- Switch SSE stream creation to
EventSources.createFactory(okHttpClient).newEventSource(...). - Force SSE requests to bypass caches via
CacheControl.FORCE_NETWORK. - Add a comprehensive
SSEStreamTestsuite covering parsing, resume behavior, and failure propagation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/org/stellar/sdk/requests/SSEStream.java | Uses OkHttp public SSE factory and forces network (no-cache) for streaming requests; clarifies liveness behavior. |
| src/test/kotlin/org/stellar/sdk/requests/SSEStreamTest.kt | Adds MockWebServer-based tests for SSE event parsing, reconnect/resume, and failure handling. |
| CHANGELOG.md | Notes the fix/refactor in the Pending section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.