diff options
author | Tatu Lund <tatu@vaadin.com> | 2020-04-07 16:38:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 16:38:44 +0300 |
commit | 368f350c98053f75a317c3430929e9eb0a388f23 (patch) | |
tree | ee867565e03c5d6f96af73bc917948d52bbb9cdf | |
parent | 4c4fbedd03c4fca7542016094d87606328ad9e58 (diff) | |
download | vaadin-framework-368f350c98053f75a317c3430929e9eb0a388f23.tar.gz vaadin-framework-368f350c98053f75a317c3430929e9eb0a388f23.zip |
Determine Push transport before re-connect (#11884)
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/11299
This bug may have been manifesting in other ways as well
Recently similar fix was done in Flow as well, see: https://github.com/vaadin/flow/pull/7489
-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 6344f7386f..030d4323ef 100644 --- a/server/src/main/java/com/vaadin/server/communication/PushHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/PushHandler.java @@ -198,18 +198,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); @@ -281,7 +279,7 @@ public class PushHandler { } } finally { try { - if (websocket) { + if (isWebsocket) { service.requestEnd(vaadinRequest, null, session); } } catch (Exception e) { @@ -520,7 +518,7 @@ public class PushHandler { * The related atmosphere resources */ void onConnect(AtmosphereResource resource) { - callWithUi(resource, establishCallback, false); + callWithUi(resource, establishCallback); } /** @@ -531,8 +529,7 @@ public class PushHandler { * The related atmosphere resources */ void onMessage(AtmosphereResource resource) { - callWithUi(resource, receiveCallback, - resource.transport() == TRANSPORT.WEBSOCKET); + callWithUi(resource, receiveCallback); } /** |