From f1d990db156500ad456dc2567b246b73c3ea2a8f Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Tue, 26 Apr 2011 12:00:55 +0000 Subject: [PATCH] Fixes #5423 Warns serverside if widgetset does not match vaadin version svn changeset:18464/svn branch:6.6 --- .../gwt/client/ApplicationConnection.java | 4 +++- .../server/AbstractApplicationPortlet.java | 19 +++++++++++++++++++ .../server/AbstractApplicationServlet.java | 18 ++++++++++++++++++ .../vaadin/terminal/gwt/server/Constants.java | 9 +++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 3d2bd950ac..d5d9578bd9 100755 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -352,6 +352,7 @@ public class ApplicationConnection { int screenHeight = BrowserInfo.get().getScreenHeight(); int tzOffset = BrowserInfo.get().getTimezoneOffset(); int rtzOffset = BrowserInfo.get().getRawTimezoneOffset(); + String widgetsetVersion = ApplicationConfiguration.VERSION; String token = History.getToken(); @@ -361,7 +362,8 @@ public class ApplicationConnection { String parameters = "repaintAll=1&" + "sh=" + screenHeight + "&sw=" + screenWidth + "&cw=" + clientWidth + "&ch=" + clientHeight + "&vw=" + offsetWidth + "&vh=" + offsetHeight + "&fr=" + token - + "&tzo=" + tzOffset + "&rtzo=" + rtzOffset; + + "&tzo=" + tzOffset + "&rtzo=" + rtzOffset + "&wsver=" + + widgetsetVersion; return parameters; } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 8717a080b8..ed7ba10ec4 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -127,6 +127,21 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } + /** + * Checks that the version reported by the client (widgetset) matches that + * of the server. + * + * @param request + */ + private void checkWidgetsetVersion(PortletRequest request) { + if (!AbstractApplicationServlet.VERSION.equals(getHTTPRequestParameter( + request, "wsver"))) { + logger.warning(String.format(WIDGETSET_MISMATCH_INFO, + AbstractApplicationServlet.VERSION, + getHTTPRequestParameter(request, "wsver"))); + } + } + private void checkProductionMode() { // Check if the application is in production mode. // We are in production mode if Debug=false or productionMode=true @@ -431,6 +446,10 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return; } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests + if (isRepaintAll(request)) { + // warn if versions do not match + checkWidgetsetVersion(request); + } applicationManager.handleUidlRequest( (ResourceRequest) request, (ResourceResponse) response, this, window); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 73b493ed41..6752f6013b 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -236,6 +236,19 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } } + /** + * Checks that the version reported by the client (widgetset) matches that + * of the server. + * + * @param request + */ + private void checkWidgetsetVersion(HttpServletRequest request) { + if (!VERSION.equals(request.getParameter("wsver"))) { + logger.warning(String.format(WIDGETSET_MISMATCH_INFO, VERSION, + request.getParameter("wsver"))); + } + } + private void checkProductionMode() { // Check if the application is in production mode. // We are in production mode if Debug=false or productionMode=true @@ -399,6 +412,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements return; } + if (isRepaintAll(request)) { + // warn if versions do not match + checkWidgetsetVersion(request); + } + Application application = null; boolean transactionStarted = false; boolean requestStarted = false; diff --git a/src/com/vaadin/terminal/gwt/server/Constants.java b/src/com/vaadin/terminal/gwt/server/Constants.java index b23a9c1284..d60d723e24 100644 --- a/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/src/com/vaadin/terminal/gwt/server/Constants.java @@ -29,6 +29,15 @@ public interface Constants { + "in web.xml. The default of 1h will be used.\n" + "==========================================================="; + static final String WIDGETSET_MISMATCH_INFO = "\n" + + "=================================================================\n" + + "The widgetset in use does not seem to be built for the Vaadin\n" + + "version in use. This might cause strange problems - a\n" + + "recompile/deploy is strongly recommended.\n" + + " Vaadin version: %s\n" + + " Widgetset version: %s\n" + + "================================================================="; + static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; -- 2.39.5