You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2012/02/21 11:06:34 UTC

DO NOT REPLY [Bug 52722] New: An incomplete fix for the resource leak bug in HTMLManagerServlet.java

https://issues.apache.org/bugzilla/show_bug.cgi?id=52722

             Bug #: 52722
           Summary: An incomplete fix for the resource leak bug in
                    HTMLManagerServlet.java
           Product: Tomcat 6
           Version: unspecified
          Platform: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Manager application
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: lianggt08@sei.pku.edu.cn
    Classification: Unclassified


The fix revision 412780 was aimed to remove an resource leak bug on the  
PrintWriter object "writer "in the method "cacheContext" of the file 
"/tomcat/tc6.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java"
, but it is incomplete. 

When the statements at lines 309-540 throw any eception, the objects
"writer"can 
not be closed as expected. The best way to close such resource object is
putting  
such close operations in the finaly block of a try-catch-finally structure.

The buggy code in the head revision is copied  as bellows:

 public void list(HttpServletRequest request,
                     HttpServletResponse response,
                     String message) throws IOException {

        if (debug >= 1)
            log("list: Listing contexts for virtual host '" +
                host.getName() + "'");

308        PrintWriter writer = response.getWriter();

        // HTML Header Section
        writer.print(Constants.HTML_HEADER_SECTION);
。。。。。

        // Finish up the response
        writer.flush();
541        writer.close();
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52722] An incomplete fix for the resource leak bug in HTMLManagerServlet.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52722

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Mark Thomas <ma...@apache.org> 2012-03-12 08:37:22 UTC ---
My statements in comment 1 are correct. If you don't understand them, the users
list is the place to ask for an explanation, not Bugzilla.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52722] An incomplete fix for the resource leak bug in HTMLManagerServlet.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52722

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
         OS/Version|                            |All

--- Comment #1 from Mark Thomas <ma...@apache.org> 2012-03-09 20:24:51 UTC ---
r412780 had nothing to do with resolving a resource leak.

There is no "cacheContext" method in the quoted class.

Having tracked down the correct code, there is no leak here. The container
*always* closing the Stream/Writer regardless of whether the app does or not.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 52722] An incomplete fix for the resource leak bug in HTMLManagerServlet.java

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52722

lianggt08@sei.pku.edu.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #2 from lianggt08@sei.pku.edu.cn 2012-03-12 08:11:28 UTC ---
The buggy method is "list()" at line 300 in the file
"/tomcat/tc6.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java"
(head revision 1226777)

please reconsider this resource leak. 

When the statements at lines 309-540 throw any eception, the objects
"writer"can not be closed as expected. 

You said that "The container
*always* closing the Stream/Writer regardless of whether the app does or not",
what is about your stated "container"? How to guaranteeing its normal
execution? what if any other caller invokes this method ?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org