You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/04/03 01:24:20 UTC

svn commit: r1584213 - in /lucene/dev/trunk/solr: ./ core/src/java/org/apache/solr/servlet/

Author: uschindler
Date: Wed Apr  2 23:24:19 2014
New Revision: 1584213

URL: http://svn.apache.org/r1584213
Log:
SOLR-5951: Fixed SolrDispatchFilter to throw useful exception on startup if SLF4j logging jars are missing

Added:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java   (with props)
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java   (with props)
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java   (with props)
Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1584213&r1=1584212&r2=1584213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Apr  2 23:24:19 2014
@@ -188,6 +188,9 @@ Bug Fixes
 * SOLR-5943: SolrCmdDistributor does not distribute the openSearcher parameter.
   (ludovic Boutros via shalin)
 
+* SOLR-5951: Fixed SolrDispatchFilter to throw useful exception on startup if
+  SLF4j logging jars are missing.  (Uwe Schindler, Hossman, Shawn Heisey)
+
 Optimizations
 ----------------------
 * SOLR-1880: Distributed Search skips GET_FIELDS stage if EXECUTE_QUERY

Added: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java?rev=1584213&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java (added)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java Wed Apr  2 23:24:19 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.servlet;
+
+import javax.servlet.Filter;
+
+/**
+ * All Solr filters available to the user's webapp should
+ * extend this class and not just implement {@link Filter}.
+ * This class ensures that the logging configuration is correct
+ * before any Solr specific code is executed.
+ */
+abstract class BaseSolrFilter implements Filter {
+  
+  static {
+    CheckLoggingConfiguration.check();
+  }
+  
+}

Added: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java?rev=1584213&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java (added)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java Wed Apr  2 23:24:19 2014
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.servlet;
+
+import javax.servlet.http.HttpServlet;
+
+/**
+ * All Solr servlets available to the user's webapp should
+ * extend this class and not {@link HttpServlet}.
+ * This class ensures that the logging configuration is correct
+ * before any Solr specific code is executed.
+ */
+@SuppressWarnings("serial")
+abstract class BaseSolrServlet extends HttpServlet {
+  
+  static {
+    CheckLoggingConfiguration.check();
+  }
+  
+}

Added: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java?rev=1584213&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java (added)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java Wed Apr  2 23:24:19 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.servlet;
+
+import org.slf4j.LoggerFactory;
+
+final class CheckLoggingConfiguration {
+  
+  static void check() {
+    try {
+      LoggerFactory.getLogger(CheckLoggingConfiguration.class);
+    } catch (NoClassDefFoundError e) {
+      throw new NoClassDefFoundError("Failed to initialize Apache Solr: "
+          +"Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in "
+          +"the jetty lib/ext directory. For other containers, the corresponding directory should be used. "
+          +"For more information, see: http://wiki.apache.org/solr/SolrLogging");
+    }  
+  }
+  
+  private CheckLoggingConfiguration() {}
+    
+}

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java?rev=1584213&r1=1584212&r2=1584213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java Wed Apr  2 23:24:19 2014
@@ -23,7 +23,6 @@ import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -38,7 +37,7 @@ import org.apache.solr.core.SolrCore;
  * 
  * @since solr 4.0
  */
-public final class LoadAdminUiServlet extends HttpServlet {
+public final class LoadAdminUiServlet extends BaseSolrServlet {
 
   @Override
   public void doGet(HttpServletRequest request,

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java?rev=1584213&r1=1584212&r2=1584213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java Wed Apr  2 23:24:19 2014
@@ -21,14 +21,13 @@ import java.io.IOException;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 /**
  * A Simple redirection servlet to help us deprecate old UI elements
  */
-public class RedirectServlet extends HttpServlet{
+public class RedirectServlet extends BaseSolrServlet {
   
   static final String CONTEXT_KEY = "${context}";
   

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1584213&r1=1584212&r2=1584213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Wed Apr  2 23:24:19 2014
@@ -73,7 +73,6 @@ import org.apache.solr.util.FastWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
@@ -107,13 +106,12 @@ import java.util.Set;
  *
  * @since solr 1.2
  */
-public class SolrDispatchFilter implements Filter
-{
+public class SolrDispatchFilter extends BaseSolrFilter {
   private static final String CONNECTION_HEADER = "Connection";
   private static final String TRANSFER_ENCODING_HEADER = "Transfer-Encoding";
   private static final String CONTENT_LENGTH_HEADER = "Content-Length";
 
-  final Logger log;
+  static final Logger log = LoggerFactory.getLogger(SolrDispatchFilter.class);
 
   protected volatile CoreContainer cores;
 
@@ -124,16 +122,6 @@ public class SolrDispatchFilter implemen
   private static final Charset UTF8 = StandardCharsets.UTF_8;
 
   public SolrDispatchFilter() {
-    try {
-      log = LoggerFactory.getLogger(SolrDispatchFilter.class);
-    } catch (NoClassDefFoundError e) {
-      throw new SolrException(
-          ErrorCode.SERVER_ERROR,
-          "Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in "
-          +"the jetty lib/ext directory. For other containers, the corresponding directory should be used. "
-          +"For more information, see: http://wiki.apache.org/solr/SolrLogging",
-          e);
-    }
   }
   
   @Override

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java?rev=1584213&r1=1584212&r2=1584213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java Wed Apr  2 23:24:19 2014
@@ -26,7 +26,6 @@ import java.util.Date;
 import java.util.List;
 
 import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -50,7 +49,7 @@ import org.slf4j.LoggerFactory;
  *
  * @since solr 4.0
  */
-public final class ZookeeperInfoServlet extends HttpServlet {
+public final class ZookeeperInfoServlet extends BaseSolrServlet {
   static final Logger log = LoggerFactory.getLogger(ZookeeperInfoServlet.class);
   
   @Override