From c030e9d2d102a5d3cfd3b63f177495c619bf8b72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Fri, 12 Apr 2013 14:31:49 +0300 Subject: [PATCH] Add isPushRequest() check to VaadinServletService.isOtherRequest() (#11556) * Prevents VaadinService from creating a new session for push requests * Also unify behaviour when UI is not found in session (log and return) Change-Id: Iea0e4ae5e0b5fa81404f688aa6d92d16343ebd26 --- .../src/com/vaadin/server/VaadinServletService.java | 5 +++-- .../com/vaadin/server/communication/PushHandler.java | 5 ++++- .../vaadin/server/communication/ServerRpcHandler.java | 11 +---------- .../server/communication/UidlRequestHandler.java | 5 +++++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index ba78efa9bb..4ae70c1c3b 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -190,8 +190,9 @@ public class VaadinServletService extends VaadinService { && !ServletUIInitHandler.isUIInitRequest(request) && !ServletPortletHelper.isFileUploadRequest(request) && !ServletPortletHelper.isHeartbeatRequest(request) - && !ServletPortletHelper.isPublishedFileRequest(request) && !ServletPortletHelper - .isUIDLRequest(request)); + && !ServletPortletHelper.isPublishedFileRequest(request) + && !ServletPortletHelper.isUIDLRequest(request) && !ServletPortletHelper + .isPushRequest(request)); } @Override diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index b2994d547f..15da4c3707 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -82,7 +82,10 @@ public class PushHandler implements AtmosphereHandler { try { UI ui = service.findUI(vaadinRequest); if (ui == null) { - throw new RuntimeException("UI not found!"); + // This should not happen + getLogger().warning( + "Could not find the requested UI in session"); + return; } assert ui.getPushConnection() instanceof AtmospherePushConnection; AtmospherePushConnection connection = (AtmospherePushConnection) ui diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java index da146abe3f..6f67cee680 100644 --- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java +++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java @@ -77,7 +77,7 @@ public class ServerRpcHandler implements Serializable { * variable changes) and executes the calls. * * @param ui - * The {@link UI} receiving the calls. + * The {@link UI} receiving the calls. Cannot be null. * @param reader * The {@link Reader} used to read the JSON. * @param request @@ -91,15 +91,6 @@ public class ServerRpcHandler implements Serializable { */ public void handleRpc(UI ui, Reader reader, VaadinRequest request) throws IOException, InvalidUIDLSecurityKeyException, JSONException { - - // Verify that there's an UI - if (ui == null) { - // This should not happen, no windows exists but - // session is still open. - getLogger().warning("Could not get UI for session"); - return; - } - ui.getSession().setLastRequestTimestamp(System.currentTimeMillis()); // Change all variables based on request parameters diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java index 32f9df3eff..ef627a818b 100644 --- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java +++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java @@ -69,6 +69,11 @@ public class UidlRequestHandler extends SynchronizedRequestHandler { return false; } UI uI = session.getService().findUI(request); + if (uI == null) { + // This should not happen + getLogger().warning("Could not find the requested UI in session"); + return true; + } checkWidgetsetVersion(request); String requestThemeName = request.getParameter("theme"); -- 2.39.5