From eed51a5d58d4318816f1c0f13cc19c9b4e91731c Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 12 Apr 2013 10:44:41 +0300 Subject: Ignore duplicate ?restartApplication during UI init (#11587) Change-Id: I8d3519bbf0ec47ec66bf08faea15ca00eb45af66 --- server/src/com/vaadin/server/BootstrapHandler.java | 13 +++++++++++++ server/src/com/vaadin/server/VaadinService.java | 15 +++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index d4f1ad308a..822db77b7d 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -54,6 +54,13 @@ import com.vaadin.ui.UI; @Deprecated public abstract class BootstrapHandler extends SynchronizedRequestHandler { + /** + * Parameter that is added to the UI init request if the session has already + * been restarted when generating the bootstrap HTML and ?restartApplication + * should thus be ignored when handling the UI init request. + */ + public static final String IGNORE_RESTART_PARAM = "ignoreRestart"; + protected class BootstrapContext implements Serializable { private final VaadinResponse response; @@ -428,6 +435,12 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { appConfig.put("theme", themeName); } + // Ignore restartApplication that might be passed to UI init + if (request + .getParameter(VaadinService.URL_PARAMETER_RESTART_APPLICATION) != null) { + appConfig.put("extraParams", "&" + IGNORE_RESTART_PARAM + "=1"); + } + JSONObject versionInfo = new JSONObject(); versionInfo.put("vaadinVersion", Version.getFullVersion()); appConfig.put("versionInfo", versionInfo); diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index ceabaaf729..86ccf00a78 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -590,10 +590,12 @@ public abstract class VaadinService implements Serializable, Callback { * not specifically requested to close or restart it. */ - final boolean restartApplication = (request - .getParameter(URL_PARAMETER_RESTART_APPLICATION) != null); - final boolean closeApplication = (request - .getParameter(URL_PARAMETER_CLOSE_APPLICATION) != null); + final boolean restartApplication = hasParameter(request, + URL_PARAMETER_RESTART_APPLICATION) + && !hasParameter(request, + BootstrapHandler.IGNORE_RESTART_PARAM); + final boolean closeApplication = hasParameter(request, + URL_PARAMETER_CLOSE_APPLICATION); if (restartApplication) { closeSession(session, request.getWrappedSession(false)); @@ -624,6 +626,11 @@ public abstract class VaadinService implements Serializable, Callback { } + private static boolean hasParameter(VaadinRequest request, + String parameterName) { + return request.getParameter(parameterName) != null; + } + /** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. -- cgit v1.2.3