]> source.dussan.org Git - vaadin-framework.git/commitdiff
Do not prevent deployment if Atmosphere init fails (#13199)
authorArtur Signell <artur@vaadin.com>
Fri, 21 Feb 2014 20:07:24 +0000 (22:07 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 21 Feb 2014 23:22:32 +0000 (01:22 +0200)
Change-Id: I07e23bcdea6b2bd23a37651a804a537690fb1311

server/src/com/vaadin/server/VaadinServletService.java
server/src/com/vaadin/server/communication/PushRequestHandler.java

index 818f2e87c69ce25444f71fd9ae7a62db8a5f4670..daefad0644ef91f87412dc73e4f93ef0d7c152c1 100644 (file)
@@ -37,7 +37,7 @@ import com.vaadin.ui.UI;
 public class VaadinServletService extends VaadinService {
     private final VaadinServlet servlet;
 
-    private final static boolean atmosphereAvailable = checkAtmosphereSupport();
+    private boolean atmosphereAvailable = checkAtmosphereSupport();
 
     /**
      * Keeps track of whether a warning about missing push support has already
@@ -66,11 +66,13 @@ public class VaadinServletService extends VaadinService {
     private static boolean checkAtmosphereSupport() {
         try {
             String rawVersion = Version.getRawVersion();
-            if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION.equals(rawVersion)) {
+            if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION
+                    .equals(rawVersion)) {
                 getLogger().log(
                         Level.WARNING,
                         Constants.INVALID_ATMOSPHERE_VERSION_WARNING,
-                        new Object[] { Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION,
+                        new Object[] {
+                                Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION,
                                 rawVersion });
             }
             return true;
@@ -86,7 +88,18 @@ public class VaadinServletService extends VaadinService {
         handlers.add(0, new ServletBootstrapHandler());
         handlers.add(new ServletUIInitHandler());
         if (atmosphereAvailable) {
-            handlers.add(new PushRequestHandler(this));
+            try {
+                handlers.add(new PushRequestHandler(this));
+            } catch (ServiceException e) {
+                // Atmosphere init failed. Push won't work but we don't throw a
+                // service exception as we don't want to prevent non-push
+                // applications from working
+                getLogger()
+                        .log(Level.WARNING,
+                                "Error initializing Atmosphere. Push will not work.",
+                                e);
+                atmosphereAvailable = false;
+            }
         }
         return handlers;
     }
index aff07d96d7be889cc0d1e96826cdaeb788ceb84f..272dd8e05c2e0e05432c9a558ed9204d83c72eb0 100644 (file)
@@ -104,7 +104,7 @@ public class PushRequestHandler implements RequestHandler,
             trackMessageSize.configure(atmosphere.getAtmosphereConfig());
             atmosphere.interceptor(trackMessageSize);
         } catch (ServletException e) {
-            throw new ServiceException("Could not read atmosphere settings", e);
+            throw new ServiceException("Atmosphere init failed", e);
         }
     }