From badf9f27dac3457c797a07bb383a6f30088c336b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 21 Feb 2014 22:07:24 +0200 Subject: [PATCH] Do not prevent deployment if Atmosphere init fails (#13199) Change-Id: I07e23bcdea6b2bd23a37651a804a537690fb1311 --- .../vaadin/server/VaadinServletService.java | 21 +++++++++++++++---- .../communication/PushRequestHandler.java | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 818f2e87c6..daefad0644 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -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; } diff --git a/server/src/com/vaadin/server/communication/PushRequestHandler.java b/server/src/com/vaadin/server/communication/PushRequestHandler.java index aff07d96d7..272dd8e05c 100644 --- a/server/src/com/vaadin/server/communication/PushRequestHandler.java +++ b/server/src/com/vaadin/server/communication/PushRequestHandler.java @@ -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); } } -- 2.39.5