-
-
Notifications
You must be signed in to change notification settings - Fork 896
killbill/killbill-platform#126 - add dedicated filter to bypass enableResponseBuffering #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
killbill/killbill-platform#126 - add dedicated filter to bypass enableResponseBuffering #2169
Conversation
…ng() if request is text/event-stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a dedicated filter to fix SSE (Server-Sent Events) compatibility issues with Jersey by bypassing response buffering for event-stream responses.
- Adds
EventStreamResponseFilterto detect text/event-stream responses and wrap Jersey'sContainerResponseWriter - Configures the filter to always return false for
enableResponseBuffering()on SSE responses - Includes comprehensive test coverage for the filter behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| EventStreamResponseFilter.java | New filter that wraps ContainerResponseWriter to disable buffering for SSE responses |
| KillbillGuiceListener.java | Registers the new EventStreamResponseFilter with Jersey |
| TestEventStreamResponseFilter.java | Comprehensive test suite covering filter behavior for SSE and non-SSE responses |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Could you explain how this fix - assuming it works - helps with solving killbill/killbill-platform#126. Which other fix would we require? Are we sure this fix is required?
Regarding the fix itself, could you set a breakpoint when doing regular request and doing SSE to check that it works as expected? |
|
About,
I hope video below is enough:
platform-126-normal-request-vs-sse.webm |
|
Additionally, I post another video about error:
platform-126-with-master-branch-errors.webm |
|
Now in this section I'll explain about another error :
platform-126-with-event-filter-branch-error.webm |
|
Summary:
So, even without PR in killbill-platform, the |
When Jersey writing a response, it try to set Content-Length header before writing the body [1]. While this is normal for non text/stream response, it breaks SSE since data the data need to flow as a continuous stream.
EventStreamResponseFiltersolves that incompatibility. It detects text/event-stream responses and wraps Jersey’sContainerResponseWritersoenableResponseBuffering()always returns false. The rest of the pipeline stays untouched.But in the end, this PR alone wont fix killbill/killbill-platform#126. We need another fix there.
[1] : See the source code. But I'm wondering if I'm pointed at the wrong source code. Because if this is indeed the source of truth about
enableResponseBuffering()that simply returntrue, then how Jersey's setServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFERconfiguration into account ?