Bug 37407 - file descriptor leak in jasper
Summary: file descriptor leak in jasper
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.12
Hardware: Other Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2005-11-08 18:05 UTC by fred
Modified: 2005-11-18 07:36 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description fred 2005-11-08 18:05:36 UTC
On my linux system I was in the proc directory for tomcat and noticed that
for each jsp file that was compiled I was ending up with two file
descriptors that were never closed.

I made the following change to JspReader and the problem seems to have gone
away.  I don't know what is causing the jsp files to be "reregistered"
multiple times that in turn causes the descriptor leak to appear.  Also I
am assuming there that err.jspError() always throws an Exception.  You could
also put the err.jspErrror() call inside the try/catch, but then you would have
to check for the type of exception in the catch block.

My impression is that it should never lead pushFile() with the reader still

diff -C5 JspReader.java JspReader.java.new
*** JspReader.java      2005-09-23 09:45:24.000000000 -0400
--- JspReader.java.new  2005-11-08 12:04:14.000000000 -0500
*** 513,522 ****
--- 513,527 ----
          String longName = file;
          int fileid = registerSourceFile(longName);
          if (fileid == -1) {
+             if (reader != null) {
+                 try {
+                     reader.close();
+                 } catch (Exception any) {}
+             }
              err.jspError("jsp.error.file.already.registered", file);
          currFileId = fileid;
Comment 1 Yoav Shapira 2005-11-18 16:09:43 UTC
Makes sense to me: thanks for reporting this and investigating it.  Will apply.
Comment 2 Yoav Shapira 2005-11-18 16:36:21 UTC