Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8561

SseEventSource sometimes sends partial events when being closed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.4.4, 3.3.11
    • 3.5.0, 3.3.12, 3.4.5
    • JAX-RS
    • None
    • Unknown

    Description

      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 but it causes clients to receive invalid events.

      For example if the server sends an event stream with the lines:

      id: fizz
      name: buzz
      data: Some Data
      
      id: foo
      name: bar
      data: Some Other Data
      
      <EOF>
      

      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.

      Attachments

        Issue Links

          Activity

            People

              reta Andriy Redko
              timothyjward Timothy James Ward
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: