[
https://issues.apache.org/jira/browse/CXF-8561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17374451#comment-17374451
]
Andriy Redko commented on CXF-8561:
-----------------------------------
Hi [~timothyjward] , I think your expectation make sense, as per SSE spec [1]:
> Once the end of the file is reached, any pending data must be discarded. (If
> the file ends in the middle of an event, before the final empty line, the
> incomplete event is not dispatched.)
So yes, the incomplete events should not be dispatched, thank you.
[1]
https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
> SseEventSource sometimes sends partial events when being closed
> ---------------------------------------------------------------
>
> Key: CXF-8561
> URL: https://issues.apache.org/jira/browse/CXF-8561
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.4.4
> Reporter: Timothy James Ward
> Priority: Major
>
> The JAX-RS SseEventSource can be closed by calling the close method. If this
> is done while the SseEventSource is in the middle of receiving an event then
> sometimes a partial event is delivered to the callback function.
> This is clearly deliberate [as seen in the
> source|https://github.com/apache/cxf/blame/2aed55612a1da770d5ef554b551407881a210289/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/InboundSseEventProcessor.java#L118-L120]
> but it causes clients to receive invalid events.
> For example if the server sends an event stream with the lines:
> {noformat}
> id: fizz
> name: buzz
> data: Some Data
> id: foo
> name: bar
> data: Some Other Data
> <EOF>
> {noformat}
> but the client is closed during the reception of the second event then the
> client may
> receive an event with one of:
> * Just an id and no name or data
> * An id and name, but no data
> * The complete event
> This situation is not theoretical. The integration tests for my product have
> become unstable due to this behaviour, which I have to work around.
> The correct behaviour would be to not send any pending but potentially
> incomplete event at the end of the stream. A valid event stream will always
> terminate with an empty line to indicate the end of the final event, so there
> should be no need for cleanup.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)