summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-04-26 15:53:13 +0300
committerArtur Signell <artur@vaadin.com>2013-04-26 15:56:22 +0300
commited97f8bcdd7472710ea8ddd88b74bd88016c510b (patch)
treeb077dafb8a3fcec7b2a2fed7e2cdea88231d1289 /server
parentd8e0a553f497f0ea40bee0aaaef20aa5cc369685 (diff)
downloadvaadin-framework-ed97f8bcdd7472710ea8ddd88b74bd88016c510b.tar.gz
vaadin-framework-ed97f8bcdd7472710ea8ddd88b74bd88016c510b.zip
Send communication error if UI with given id is not found (#11485)
Change-Id: I83da8e1732296b6549a56de62b8c09660e39a8ec
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/PushHandler.java11
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java33
2 files changed, 39 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java
index 0b3401ec1d..1277fe88c5 100644
--- a/server/src/com/vaadin/server/communication/PushHandler.java
+++ b/server/src/com/vaadin/server/communication/PushHandler.java
@@ -258,9 +258,14 @@ public class PushHandler implements AtmosphereHandler {
// Sets UI.currentInstance
final UI ui = service.findUI(vaadinRequest);
if (ui == null) {
- // This should not happen
- getLogger().warning(
- "Could not find the requested UI in session");
+ // This a request through an already open push connection to
+ // a UI which no longer exists.
+ resource.getResponse()
+ .getWriter()
+ .write(UidlRequestHandler.getUINotFoundErrorJSON(
+ service, vaadinRequest));
+ // End the connection
+ resource.resume();
return;
}
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index 053426f90e..04ff5f9e87 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -71,8 +71,10 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
}
UI uI = session.getService().findUI(request);
if (uI == null) {
- // This should not happen
- getLogger().warning("Could not find the requested UI in session");
+ // This should not happen but it will if the UI has been closed. We
+ // really don't want to see it in the server logs though
+ response.getWriter().write(
+ getUINotFoundErrorJSON(session.getService(), request));
return true;
}
@@ -284,4 +286,31 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
return true;
}
+
+ /**
+ * Returns the JSON which should be returned to the client when a request
+ * for a non-existent UI arrives.
+ *
+ * @param service
+ * The VaadinService
+ * @param vaadinRequest
+ * The request which triggered this, or null if not available
+ * @since 7.1
+ * @return A JSON string
+ */
+ static String getUINotFoundErrorJSON(VaadinService service,
+ VaadinRequest vaadinRequest) {
+ SystemMessages ci = service.getSystemMessages(
+ vaadinRequest.getLocale(), vaadinRequest);
+ // Session Expired is not really the correct message as the
+ // session exists but the requested UI does not.
+ // Using Communication Error for now.
+ String json = VaadinService.createCriticalNotificationJSON(
+ ci.getCommunicationErrorCaption(),
+ ci.getCommunicationErrorMessage(), null,
+ ci.getCommunicationErrorURL());
+
+ return json;
+ }
+
}