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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to