]> source.dussan.org Git - vaadin-framework.git/commitdiff
Avoid NoClassDefFoundError retrieving Atmosphere version (#14904).
authorDenis Anisimov <denis@vaadin.com>
Wed, 10 Dec 2014 20:17:32 +0000 (22:17 +0200)
committerVaadin Code Review <review@vaadin.com>
Thu, 18 Dec 2014 21:17:28 +0000 (21:17 +0000)
Change-Id: Id64c4c4535e250c6e0e6457dfdfd17424bdc2fd4

server/src/com/vaadin/server/BootstrapHandler.java
server/src/com/vaadin/server/VaadinServletService.java
server/src/com/vaadin/server/communication/AtmospherePushConnection.java

index 985d7ef765e6b3f5f4b3706ce8cefd5bb102e850..bfe195ccf95e79e7ab8f773db1374f610e41456a 100644 (file)
@@ -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());
index 6832da236a7fae11f85a81e237dd0f793d22479e..22848c023c707b3f79a63737dded313a831d5d87 100644 (file)
@@ -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
index a274fbbb9b736aa3f242905287aeb63f30fadb19..0819a24ee95c2547417085aa1f479ce0658ea7ee 100644 (file)
@@ -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.
      */