Bug 32429

Summary: sendToLog calculates line count incorrectly.
Product: Tomcat 4 Reporter: Mark Claassen <mac>
Component: Servlets:CGIAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.1.31   
Target Milestone: ---   
Hardware: PC   
OS: All   

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?