tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43009] New: - Reported exception is not original cause of problem
Date Wed, 01 Aug 2007 14:21:50 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43009>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43009

           Summary: Reported exception is not original cause of problem
           Product: Tomcat 5
           Version: 5.5.23
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Webapps:Manager
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: d.alexander@lse.ac.uk


In this method from org.apache.catalina.manager.ManagerServlet

protected void uploadWar(HttpServletRequest request, File war)
    throws IOException {

        ...

        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            ...
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
          ...
        }
   ...
}

If an Exception is thrown while creating the OutputStream to write the war (say
due to lack of write permission in appBase), the useful Exception thrown is
caught and the method attempts to clean up with a war.delete(); If an Exception
is thrown during the delete (as is quite likely), that is thrown out and logged
instead of the original more useful one.

So the catch block in the code above would be better written something like this:

        } catch (IOException originalException) {
            try {
                  war.delete();
            } catch (IOException deleteException)
                  log("Unable to clean up following ["+originalException+"] due
to ["+deleteException+"]");
                  throw originalException;
            }
        }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message