Bug 32429 - sendToLog calculates line count incorrectly.
Summary: sendToLog calculates line count incorrectly.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Servlets:CGI (show other bugs)
Version: 4.1.31
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-29 16:38 UTC by Mark Claassen
Modified: 2004-11-29 13:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Claassen 2004-11-29 16:38:39 UTC
Line count should be inside the loop.  As it is now, it will always be 1 if 
there are no stderr lines.  This code is also incorrect in 5.0.28

Line count algorithm is incorrect
        private void sendToLog(BufferedReader rdr) {
            String line = null;
            int lineCount = 0 ;
            try {
                while ((line = rdr.readLine()) != null) {
                    log("runCGI (stderr):" +  line) ;
                }
--->            lineCount++ ;
            } catch (IOException e) {
                log("sendToLog error", e) ;
            } finally {
                try {
                    rdr.close() ;
                } catch (IOException ce) {
                    log("sendToLog error", ce) ;
                } ;
            } ;
            if ( lineCount > 0 && debug > 2) {
                log("runCGI: " + lineCount + " lines received on stderr") ;
            } ;
        }
Comment 1 Mark Thomas 2004-11-29 22:44:59 UTC
Fix in CVS for 4.1.x and 5.5.x

Thanks for the patch.
Comment 2 Mark Claassen 2004-11-29 22:56:14 UTC
This is not a big deal, but can it be still fixed in 5.0.30?