From f8686d9638a4d24aef8e563a18a061310bddb24f Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Sat, 20 Oct 2018 15:14:56 -0600 Subject: [PATCH] Tweaked logging around servlet container and added warning about jetty Signed-off-by: Andrew DeMaria --- .../main/java/org/airsonic/player/Application.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/Application.java b/airsonic-main/src/main/java/org/airsonic/player/Application.java index 3f476853..25857afe 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/Application.java +++ b/airsonic-main/src/main/java/org/airsonic/player/Application.java @@ -189,6 +189,7 @@ public class Application extends SpringBootServletInitializer implements Embedde @Override public void customize(ConfigurableEmbeddedServletContainer container) { + LOG.trace("Servlet container is {}", container.getClass().getCanonicalName()); // Yes, there is a good reason we do this. // We cannot count on the tomcat classes being on the classpath which will // happen if the war is deployed to another app server like Jetty. So, we @@ -197,6 +198,7 @@ public class Application extends SpringBootServletInitializer implements Embedde try { Class tomcatESCF = Class.forName("org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory"); if(tomcatESCF.isInstance(container)) { + LOG.info("Detected Tomcat web server"); LOG.debug("Attempting to optimize tomcat"); Object tomcatESCFInstance = tomcatESCF.cast(container); Class tomcatApplicationClass = Class.forName("org.airsonic.player.TomcatApplication"); @@ -207,10 +209,19 @@ public class Application extends SpringBootServletInitializer implements Embedde LOG.debug("Skipping tomcat optimization as we are not running on tomcat"); } } catch (NoClassDefFoundError | ClassNotFoundException e) { - LOG.debug("Skipping tomcat optimization as the tomcat classes are not available"); + LOG.debug("No tomcat classes found"); } catch (Exception e) { LOG.warn("An error happened while trying to optimize tomcat", e); } + + try { + Class jettyESCF = Class.forName("org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory"); + if(jettyESCF.isInstance(container)) { + LOG.warn("Detected Jetty web server. Here there be dragons."); + } + } catch (NoClassDefFoundError | ClassNotFoundException e) { + LOG.debug("No jetty classes found"); + } } public static void main(String[] args) {