From 11129786c4591e768c018db2d3e39be1b21caa2d Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Wed, 10 Dec 2014 22:17:32 +0200 Subject: Avoid NoClassDefFoundError retrieving Atmosphere version (#14904). Change-Id: Id64c4c4535e250c6e0e6457dfdfd17424bdc2fd4 --- server/src/com/vaadin/server/BootstrapHandler.java | 9 +++++-- .../com/vaadin/server/VaadinServletService.java | 28 ++++++++++------------ .../communication/AtmospherePushConnection.java | 11 +++++++++ 3 files changed, 31 insertions(+), 17 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 985d7ef765..bfe195ccf9 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -39,6 +39,7 @@ import org.jsoup.parser.Tag; import com.vaadin.annotations.Viewport; import com.vaadin.annotations.ViewportGeneratorClass; +import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; import com.vaadin.shared.communication.PushMode; @@ -505,8 +506,12 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { JsonObject versionInfo = Json.createObject(); versionInfo.put("vaadinVersion", Version.getFullVersion()); - versionInfo.put("atmosphereVersion", - org.atmosphere.util.Version.getRawVersion()); + String atmosphereVersion = AtmospherePushConnection + .getAtmosphereVersion(); + if (atmosphereVersion != null) { + versionInfo.put("atmosphereVersion", atmosphereVersion); + } + appConfig.put("versionInfo", versionInfo); appConfig.put("widgetset", context.getWidgetsetName()); diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 6832da236a..22848c023c 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -27,8 +27,7 @@ import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import org.atmosphere.util.Version; - +import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.server.communication.PushRequestHandler; import com.vaadin.server.communication.ServletBootstrapHandler; import com.vaadin.server.communication.ServletUIInitHandler; @@ -54,21 +53,20 @@ public class VaadinServletService extends VaadinService { } private static boolean checkAtmosphereSupport() { - try { - String rawVersion = Version.getRawVersion(); - if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION - .equals(rawVersion)) { - getLogger().log( - Level.WARNING, - Constants.INVALID_ATMOSPHERE_VERSION_WARNING, - new Object[] { - Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION, - rawVersion }); - } - return true; - } catch (NoClassDefFoundError e) { + String rawVersion = AtmospherePushConnection.getAtmosphereVersion(); + if (rawVersion == null) { return false; } + + if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION.equals(rawVersion)) { + getLogger().log( + Level.WARNING, + Constants.INVALID_ATMOSPHERE_VERSION_WARNING, + new Object[] { + Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION, + rawVersion }); + } + return true; } @Override diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index a274fbbb9b..0819a24ee9 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -31,6 +31,7 @@ import java.util.logging.Logger; import org.atmosphere.cpr.AtmosphereResource; import org.atmosphere.cpr.AtmosphereResource.TRANSPORT; +import org.atmosphere.util.Version; import com.vaadin.shared.communication.PushConstants; import com.vaadin.ui.UI; @@ -44,6 +45,16 @@ import com.vaadin.ui.UI; */ public class AtmospherePushConnection implements PushConnection { + public static String getAtmosphereVersion() { + try { + String v = Version.getRawVersion(); + assert v != null; + return v; + } catch (NoClassDefFoundError e) { + return null; + } + } + /** * Represents a message that can arrive as multiple fragments. */ -- cgit v1.2.3