Author: markt Date: Tue Sep 30 10:28:12 2008 New Revision: 700532 URL: http://svn.apache.org/viewvc?rev=700532&view=rev Log: Fix some more Find Bugs nags in the CGIServlet. Minor functional changes.
Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=700532&r1=700531&r2=700532&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original) +++ tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Tue Sep 30 10:28:12 2008 @@ -1143,7 +1143,11 @@ String dirPath = destPath.toString().substring( 0,destPath.toString().lastIndexOf("/")); File dir = new File(dirPath); - dir.mkdirs(); + if (!dir.mkdirs() && debug >= 2) { + log("expandCGIScript: failed to create directories for '" + + dir.getAbsolutePath() + "'"); + return; + } try { synchronized (expandFileLock) { @@ -1169,7 +1173,10 @@ } catch (IOException ioe) { // delete in case file is corrupted if (f.exists()) { - f.delete(); + if (!f.delete() && debug >= 2) { + log("expandCGIScript: failed to delete '" + + f.getAbsolutePath() + "'"); + } } } } @@ -1591,6 +1598,7 @@ * with major modifications by Martin Dengler */ Runtime rt = null; + BufferedReader cgiHeaderReader = null; InputStream cgiOutput = null; BufferedReader commandsStdErr = null; BufferedOutputStream commandsStdIn = null; @@ -1658,7 +1666,7 @@ InputStream cgiHeaderStream = new HTTPHeaderInputStream(proc.getInputStream()); - BufferedReader cgiHeaderReader = + cgiHeaderReader = new BufferedReader(new InputStreamReader(cgiHeaderStream)); while (isRunning) { @@ -1728,6 +1736,14 @@ throw e; } finally{ + // Close the header reader + if (cgiHeaderReader != null) { + try { + cgiHeaderReader.close(); + } catch (IOException ioe) { + log ("Exception closing header reader " + ioe); + } + } // Close the output stream if used if (cgiOutput != null) { try { @@ -1833,7 +1849,7 @@ * upto and including the two blank lines terminating the headers. It * allows the content to be read using bytes or characters as appropriate. */ - protected class HTTPHeaderInputStream extends InputStream { + protected static class HTTPHeaderInputStream extends InputStream { private static final int STATE_CHARACTER = 0; private static final int STATE_FIRST_CR = 1; private static final int STATE_FIRST_LF = 2; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]