Fix FindBugs warnings
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 16 Jan 2011 20:33:40 +0000 (20:33 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 16 Jan 2011 20:33:40 +0000 (20:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059655 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/Catalina.java
java/org/apache/catalina/startup/LocalStrings.properties
java/org/apache/catalina/startup/WebRuleSet.java
res/findbugs/filter-false-positives.xml

index f164ca4..751bbb6 100644 (file)
@@ -491,7 +491,9 @@ public class Catalina {
             inputStream = new FileInputStream(file);
             inputSource = new InputSource("file://" + file.getAbsolutePath());
         } catch (Exception e) {
-            // Ignore
+            if (log.isDebugEnabled()) {
+                log.debug(sm.getString("catalina.configFail", file), e);
+            }
         }
         if (inputStream == null) {
             try {
@@ -501,7 +503,10 @@ public class Catalina {
                     (getClass().getClassLoader()
                      .getResource(getConfigFile()).toString());
             } catch (Exception e) {
-                // Ignore
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("catalina.configFail",
+                            getConfigFile()), e);
+                }
             }
         }
 
@@ -510,20 +515,29 @@ public class Catalina {
         if( inputStream==null ) {
             try {
                 inputStream = getClass().getClassLoader()
-                .getResourceAsStream("server-embed.xml");
+                        .getResourceAsStream("server-embed.xml");
                 inputSource = new InputSource
                 (getClass().getClassLoader()
                         .getResource("server-embed.xml").toString());
             } catch (Exception e) {
-                // Ignore
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("catalina.configFail",
+                            "server-embed.xml"), e);
+                }
             }
         }
 
 
-        if ((inputStream == null) && (file != null)) {
-            log.warn("Can't load server.xml from " + file.getAbsolutePath());
-            if (file.exists() && !file.canRead()) {
-                log.warn("Permissions incorrect, read permission is not allowed on the file.");
+        if (inputStream == null || inputSource == null) {
+            if  (file == null) {
+                log.warn(sm.getString("catalina.configFail",
+                        getConfigFile() + "] or [server-embed.xml]"));
+            } else {
+                log.warn(sm.getString("catalina.configFail",
+                        file.getAbsolutePath()));
+                if (file.exists() && !file.canRead()) {
+                    log.warn("Permissions incorrect, read permission is not allowed on the file.");
+                }
             }
             return;
         }
index cac771b..b2912b9 100644 (file)
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+catalina.configFail=Unable to load server configuration from [{0}]
 catalina.shutdownHookFail=The shutdown hook experienced an error while trying to stop the server
 catalina.stopServer=No shutdown port configured. Shut down server through OS signal. Server not shut down.
 contextConfig.altDDNotFound=alt-dd file {0} not found
index fda97db..9561765 100644 (file)
@@ -909,6 +909,7 @@ final class CallMethodMultiRule extends CallMethodRule {
         if (paramCount > 0) {
             parameters = (Object[]) digester.popParams();
         } else {
+            parameters = new Object[0];
             super.end(namespace, name);
         }
         
index 5476ec0..b69278a 100644 (file)
     <Bug code="MSF" />
   </Match>
   <Match>
+    <!-- Catalina isn'y used when embedding -->
+    <Class name="org.apache.catalina.startup.Catalina" />
+    <Method name="stopServer" />
+    <Bug code="Dm" />
+  </Match>
+  <Match>
     <!-- Sleep is short, needs to keep lock -->
     <Class name="org.apache.catalina.startup.HostConfig" />
     <Method name="checkResources" />