diff options
author | Artur Signell <artur@vaadin.com> | 2013-11-07 11:20:54 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-11-07 09:26:41 +0000 |
commit | e9335620bb2c5e83f20cca747d687a590b8fe80c (patch) | |
tree | 6271daf3f0c50d031bc573c5e6c2cc3815baf895 /server | |
parent | 6b381737e84b5f35814994f9cc311f09f578413a (diff) | |
download | vaadin-framework-e9335620bb2c5e83f20cca747d687a590b8fe80c.tar.gz vaadin-framework-e9335620bb2c5e83f20cca747d687a590b8fe80c.zip |
Minimal fix for error handling with streaming (#12578)
There are still issues in PushHandler where the wrong resource is used but these should not be as critical. They will be fixed in #12920
Change-Id: Ife8d3694bdb6ee29c5b4adbd8988cc0346c4fe3f
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/communication/PushHandler.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index b7cc628856..09428e47a9 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -264,11 +264,12 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter return; } + UI ui = null; session.lock(); try { VaadinSession.setCurrent(session); // Sets UI.currentInstance - final UI ui = service.findUI(vaadinRequest); + ui = service.findUI(vaadinRequest); if (ui == null) { sendNotificationAndDisconnect(resource, UidlRequestHandler.getUINotFoundErrorJSON(service, @@ -282,8 +283,19 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter SystemMessages msg = service.getSystemMessages( ServletPortletHelper.findLocale(null, null, vaadinRequest), vaadinRequest); + + AtmosphereResource errorResource = resource; + if (ui != null && ui.getPushConnection() != null) { + // We MUST use the opened push connection if there is one. + // Otherwise we will write the response to the wrong request + // when using streaming (the client -> server request + // instead of the opened push channel) + errorResource = ((AtmospherePushConnection) ui + .getPushConnection()).getResource(); + } + sendNotificationAndDisconnect( - resource, + errorResource, VaadinService.createCriticalNotificationJSON( msg.getInternalErrorCaption(), msg.getInternalErrorMessage(), null, |