From: markt Date: Sun, 24 Jun 2007 11:45:44 +0000 (+0000) Subject: Close streams as noted in bug 42314. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=212fc15904a3464d90442f2a0be0198d1d73e55b;p=tomcat7.0 Close streams as noted in bug 42314. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@550210 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/JavacErrorDetail.java b/java/org/apache/jasper/compiler/JavacErrorDetail.java index 0750c5987..cf2daffe1 100644 --- a/java/org/apache/jasper/compiler/JavacErrorDetail.java +++ b/java/org/apache/jasper/compiler/JavacErrorDetail.java @@ -94,13 +94,16 @@ public class JavacErrorDetail { this.jspBeginLineNum = jspBeginLineNum; if (jspBeginLineNum > 0 && ctxt != null) { + InputStream is = null; + FileInputStream fis = null; + try { // Read both files in, so we can inspect them - String[] jspLines = readFile - (ctxt.getResourceAsStream(jspFileName)); + is = ctxt.getResourceAsStream(jspFileName); + String[] jspLines = readFile(is); - String[] javaLines = readFile - (new FileInputStream(ctxt.getServletJavaFileName())); + fis = new FileInputStream(ctxt.getServletJavaFileName()); + String[] javaLines = readFile(fis); // If the line contains the opening of a multi-line scriptlet // block, then the JSP line number we got back is probably @@ -134,6 +137,21 @@ public class JavacErrorDetail { } catch (IOException ioe) { // Can't read files - ignore + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ioe) { + // Ignore + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException ioe) { + // Ignore + } + } } } }