Close streams as noted in bug 42314.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 24 Jun 2007 11:45:44 +0000 (11:45 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 24 Jun 2007 11:45:44 +0000 (11:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@550210 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/JavacErrorDetail.java

index 0750c59..cf2daff 100644 (file)
@@ -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
+                    }
+                }
             }
         }
     }