diff options
author | Tatu Lund <tatu@vaadin.com> | 2020-05-11 09:45:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 09:45:42 +0300 |
commit | e829b469b1ef3162ffdab29d4f2197a868e7c897 (patch) | |
tree | 4df4e2f2f9287edbb5d9dfeceaa21be6e76871ad | |
parent | e99c787623e7df9aa0923e78315e9e98e5936e47 (diff) | |
download | vaadin-framework-e829b469b1ef3162ffdab29d4f2197a868e7c897.tar.gz vaadin-framework-e829b469b1ef3162ffdab29d4f2197a868e7c897.zip |
Determine Push transport before re-connect (#11988)
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
-rw-r--r-- | server/src/main/java/com/vaadin/server/communication/PushHandler.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/src/main/java/com/vaadin/server/communication/PushHandler.java b/server/src/main/java/com/vaadin/server/communication/PushHandler.java index 92ae5d554b..c210a4ee30 100644 --- a/server/src/main/java/com/vaadin/server/communication/PushHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/PushHandler.java @@ -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); } /** |