Partial fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=48644
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Sep 2010 20:24:18 +0000 (20:24 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Sep 2010 20:24:18 +0000 (20:24 +0000)
Don't catch Throwable

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1001899 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ant/AbstractCatalinaTask.java
java/org/apache/catalina/ant/ValidatorTask.java
java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java
java/org/apache/catalina/ant/jmx/JMXAccessorTask.java

index c514ce3..265cbb8 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.catalina.ant;
 
 
 import java.io.BufferedOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
@@ -262,27 +263,27 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
                 // or error line will be logged twice
                 throw new BuildException(error);
             }
-        } catch (Throwable t) {
+        } catch (Exception e) {
             if (isFailOnError()) {
-                throw new BuildException(t);
+                throw new BuildException(e);
             } else {
-                handleErrorOutput(t.getMessage());
+                handleErrorOutput(e.getMessage());
             }
         } finally {
             closeRedirector();
             if (reader != null) {
                 try {
                     reader.close();
-                } catch (Throwable u) {
-                    ExceptionUtils.handleThrowable(u);
+                } catch (IOException ioe) {
+                    // Ignore
                 }
                 reader = null;
             }
             if (istream != null) {
                 try {
                     istream.close();
-                } catch (Throwable u) {
-                    ExceptionUtils.handleThrowable(u);
+                } catch (IOException ioe) {
+                    // Ignore
                 }
                 istream = null;
             }
index f3a611a..457ad62 100644 (file)
@@ -100,11 +100,11 @@ public class ValidatorTask extends BaseRedirectorHelperTask {
             is.setByteStream(stream);
             digester.parse(is);
             handleOutput("web.xml validated");
-        } catch (Throwable t) {
+        } catch (Exception e) {
             if (isFailOnError()) {
-                throw new BuildException("Validation failure", t);
+                throw new BuildException("Validation failure", e);
             } else {
-                handleErrorOutput("Validation failure: " + t);
+                handleErrorOutput("Validation failure: " + e);
             }
         } finally {
             Thread.currentThread().setContextClassLoader(oldCL);
index e49acdd..db614b2 100644 (file)
@@ -196,11 +196,11 @@ public class JMXAccessorQueryTask extends JMXAccessorTask {
                     try {
                         value = jmxServerConnection
                                 .getAttribute(oname, attName);
-                    } catch (Throwable t) {
+                    } catch (Exception e) {
                         if (isEcho())
                             handleErrorOutput("Error getting attribute "
                                     + oname + " " + pname + attName + " "
-                                    + t.toString());
+                                    + e.toString());
                         continue;
                     }
                     if (value == null)
index b86112a..fe4a2dd 100644 (file)
@@ -351,11 +351,11 @@ public class JMXAccessorTask extends BaseRedirectorHelperTask {
                     // or error line will be logged twice
                     throw new BuildException(error);
                 }
-            } catch (Throwable t) {
+            } catch (Exception e) {
                 if (isFailOnError()) {
-                    throw new BuildException(t);
+                    throw new BuildException(e);
                 } else {
-                    handleErrorOutput(t.getMessage());
+                    handleErrorOutput(e.getMessage());
                 }
             } finally {
                 closeRedirector();