reta commented on a change in pull request #621: CXF-7996: TCK Fixes for SSE 
reconnect state tests
URL: https://github.com/apache/cxf/pull/621#discussion_r363136965
 
 

 ##########
 File path: 
rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/SseEventSourceImpl.java
 ##########
 @@ -163,38 +174,43 @@ public void open() {
             throw new IllegalStateException("The SseEventSource is already in 
" + state.get() + " state");
         }
 
-        // Create the executor for scheduling the reconnect tasks 
+        // Create the executor for scheduling the reconnect tasks
         final Configuration configuration = target.getConfiguration();
         if (executor == null) {
             executor = (ScheduledExecutorService)configuration
                 .getProperty("scheduledExecutorService");
-            
+
             if (executor == null) {
                 executor = Executors.newSingleThreadScheduledExecutor();
                 managedExecutor = false; /* we manage lifecycle */
             }
         }
-        
+
         final Object lastEventId = 
configuration.getProperty(HttpHeaders.LAST_EVENT_ID_HEADER);
         connect(lastEventId != null ? lastEventId.toString() : null);
+        // If a 503 was receieved during connect we might be in the 
"Connecting" state,  however
+        // the isOpened flag will need to be set indicating that the 
eventsource has been opened
+        // and not yet closed.
+        isOpened = true;
     }
 
     private void connect(String lastEventId) {
         final InboundSseEventListenerDelegate delegate = new 
InboundSseEventListenerDelegate();
         Response response = null;
-        
+
         try {
             Invocation.Builder builder = 
target.request(MediaType.SERVER_SENT_EVENTS);
             if (lastEventId != null) {
                 builder.header(HttpHeaders.LAST_EVENT_ID_HEADER, lastEventId);
             }
             response = builder.get();
 
-            // A client can be told to stop reconnecting using the HTTP 204 No 
Content 
+            // A client can be told to stop reconnecting using the HTTP 204 No 
Content
             // response code. In this case, we should give up.
             final int status = response.getStatus();
             if (status == 204) {
                 LOG.fine("SSE endpoint " + target.getUri() + " returns no 
data, disconnecting");
+                delegate.onComplete();
 
 Review comment:
   :+1: 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to