diff options
author | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2020-07-01 12:44:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 12:44:55 +0300 |
commit | 89dfd79a7931835a6d9416f0e2f7371495667c2c (patch) | |
tree | b0344c8ca1f9f5266a79a3efff51b2c0bde411f1 /server/src/main | |
parent | d1b3a396d890f5b6124cbc90adff9a24b76b8b1a (diff) | |
download | vaadin-framework-89dfd79a7931835a6d9416f0e2f7371495667c2c.tar.gz vaadin-framework-89dfd79a7931835a6d9416f0e2f7371495667c2c.zip |
Cherry pick 8.11.1 (#12046)
* Fix rendering of TreeGrid's frozen columns after hierarchy-column reset (#12028)
* Add tests
* Fix getVisibleFrozenColumnCount() if SelectionMode is multi
* Update ComboBox popup position comparison to use correct top value. (#12041)
Fixes #12029
* Clear thread local instances on connection lost in push handler (#12042)
Adopted from https://github.com/vaadin/flow/pull/8567
Co-authored-by: Tarek Oraby <42799254+tarekoraby@users.noreply.github.com>
Co-authored-by: Anna Koskinen <Ansku@users.noreply.github.com>
Co-authored-by: Tatu Lund <tatu@vaadin.com>
Diffstat (limited to 'server/src/main')
-rw-r--r-- | server/src/main/java/com/vaadin/server/communication/PushHandler.java | 32 |
1 files changed, 25 insertions, 7 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 030d4323ef..77dd1b9b57 100644 --- a/server/src/main/java/com/vaadin/server/communication/PushHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/PushHandler.java @@ -44,6 +44,7 @@ import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.JsonConstants; import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.UI; +import com.vaadin.util.CurrentInstance; import elemental.json.JsonException; @@ -316,13 +317,29 @@ public class PushHandler { } void connectionLost(AtmosphereResourceEvent event) { + VaadinSession session = null; + try { + session = handleConnectionLost(event); + } finally { + if (session != null) { + session.access(new Runnable() { + @Override + public void run() { + CurrentInstance.clearAll(); + } + }); + } + } + } + + private VaadinSession handleConnectionLost(AtmosphereResourceEvent event) { // We don't want to use callWithUi here, as it assumes there's a client // request active and does requestStart and requestEnd among other // things. if (event == null) { getLogger().log(Level.SEVERE, "Could not get event. This should never happen."); - return; + return null; } AtmosphereResource resource = event.getResource(); @@ -330,7 +347,7 @@ public class PushHandler { if (resource == null) { getLogger().log(Level.SEVERE, "Could not get resource. This should never happen."); - return; + return null; } VaadinServletRequest vaadinRequest = new VaadinServletRequest( @@ -342,7 +359,7 @@ public class PushHandler { } catch (ServiceException e) { getLogger().log(Level.SEVERE, "Could not get session. This should never happen", e); - return; + return null; } catch (SessionExpiredException e) { // This happens at least if the server is restarted without // preserving the session. After restart the client reconnects, gets @@ -351,7 +368,7 @@ public class PushHandler { getLogger().log(Level.FINER, "Session expired before push disconnect event was received", e); - return; + return session; } UI ui = null; @@ -375,13 +392,13 @@ public class PushHandler { getLogger().log(Level.FINE, "Could not get UI. This should never happen," + " except when reloading in Firefox and Chrome -" - + " see http://dev.vaadin.com/ticket/14251."); - return; + + " see https://github.com/vaadin/framework/issues/5449."); + return session; } else { getLogger().log(Level.INFO, "No UI was found based on data in the request," + " but a slower lookup based on the AtmosphereResource succeeded." - + " See http://dev.vaadin.com/ticket/14251 for more details."); + + " See https://github.com/vaadin/framework/issues/5449 for more details."); } } @@ -426,6 +443,7 @@ public class PushHandler { // can't call ErrorHandler, we (hopefully) don't have a lock } } + return session; } private static UI findUiUsingResource(AtmosphereResource resource, |