diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-12-10 22:17:32 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-18 21:17:28 +0000 |
commit | 11129786c4591e768c018db2d3e39be1b21caa2d (patch) | |
tree | 7a258d45333c7e9e452bb1a189cf4bff47dc9a5c | |
parent | 3f1295a9d540e223fe7cc2c39f84cf904df8b60b (diff) | |
download | vaadin-framework-11129786c4591e768c018db2d3e39be1b21caa2d.tar.gz vaadin-framework-11129786c4591e768c018db2d3e39be1b21caa2d.zip |
Avoid NoClassDefFoundError retrieving Atmosphere version (#14904).
Change-Id: Id64c4c4535e250c6e0e6457dfdfd17424bdc2fd4
3 files changed, 31 insertions, 17 deletions
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. */ |