]> source.dussan.org Git - vaadin-framework.git/commitdiff
Determine Push transport before re-connect (#11988)
authorTatu Lund <tatu@vaadin.com>
Mon, 11 May 2020 06:45:42 +0000 (09:45 +0300)
committerGitHub <noreply@github.com>
Mon, 11 May 2020 06:45:42 +0000 (09:45 +0300)
onConnect was allways called with websocket = false. I think this is wrong, since if there was connection loss in websocket, now connection cannot be re-established in websocket mode.

Fixes: https://github.com/vaadin/framework/issues/7190
Cherry pick of https://github.com/vaadin/framework/pull/11884

server/src/main/java/com/vaadin/server/communication/PushHandler.java

index 92ae5d554b2472c399bb13d3541c07efb471a879..c210a4ee305de05a8c682f4021ee4fd8f64e9cb8 100644 (file)
@@ -190,18 +190,16 @@ public class PushHandler {
      *            the atmosphere resource for the current request
      * @param callback
      *            the push callback to call when a UI is found and locked
-     * @param websocket
-     *            true if this is a websocket message (as opposed to a HTTP
-     *            request)
      */
     private void callWithUi(final AtmosphereResource resource,
-            final PushEventCallback callback, boolean websocket) {
+            final PushEventCallback callback) {
         AtmosphereRequest req = resource.getRequest();
         VaadinServletRequest vaadinRequest = new VaadinServletRequest(req,
                 service);
         VaadinSession session = null;
 
-        if (websocket) {
+        boolean isWebsocket = resource.transport() == TRANSPORT.WEBSOCKET;
+        if (isWebsocket) {
             // For any HTTP request we have already started the request in the
             // servlet
             service.requestStart(vaadinRequest, null);
@@ -273,7 +271,7 @@ public class PushHandler {
             }
         } finally {
             try {
-                if (websocket) {
+                if (isWebsocket) {
                     service.requestEnd(vaadinRequest, null, session);
                 }
             } catch (Exception e) {
@@ -499,7 +497,7 @@ public class PushHandler {
      *            The related atmosphere resources
      */
     void onConnect(AtmosphereResource resource) {
-        callWithUi(resource, establishCallback, false);
+        callWithUi(resource, establishCallback);
     }
 
     /**
@@ -510,8 +508,7 @@ public class PushHandler {
      *            The related atmosphere resources
      */
     void onMessage(AtmosphereResource resource) {
-        callWithUi(resource, receiveCallback,
-                resource.transport() == TRANSPORT.WEBSOCKET);
+        callWithUi(resource, receiveCallback);
     }
 
     /**