- Accoring to the java Sse spec, the SseEventSourceImpl.open() is supposed to be a sync/blocking method until the connection is established.
The problem with the current impl is that if the Sse connection is not established within 30 seconds, the open() method will not block any longer and then just becomes async. The user is not warn about any kind of timeout exception. More the http connection is not even killed.
- According to both java SSE and HTML5 specs:
So a legal response to a SSE request can be:
1 - 200 OK with Content-type header set to text/event-stream without no response body in this initial reponse
2 - Then later since the connection remains open, the first SSE event is sent.
So according to the way SseEventSourceImpl.open() is implemented :
The countdownLatch will be counted down on receiving the first SseEvent instead of being counted down when the connection is established, I mean on receiving the initial HTTP response code
(This is due to the fact that eventInput = request.get(SseEventInputImpl.class); in EventHandler.run() will wait for a response body to be available before returning.)