Timothy James Ward created CXF-8561:
---------------------------------------

             Summary: 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


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)

Reply via email to