Bug 30427 - Response contents can be truncated prematurely
Summary: Response contents can be truncated prematurely
Status: RESOLVED LATER
Alias: None
Product: Taglibs
Classification: Unclassified
Component: IO Taglib (show other bugs)
Version: 1.0
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-01 14:57 UTC by David Goodenough
Modified: 2009-11-29 19:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Goodenough 2004-08-01 14:57:48 UTC
I think I have found a problem in the IO taglib.   
 
I have a site where I use JSP with JSTL and the IO taglibs to provide a 
web frount end to a servlet which takes XML requests and delivers 
XML responses (this is used by some embedded systems as well as 
the web UI). 
 
Every now and then I get a null response back from the servlet when 
using the IO taglib.  The embedded systems never hit this problem. 
The log at the Servlet indicates that a response was sent, and ethereal 
concures. 
 
Originally the servlet only accepted https requests, even from the 
web UI, and this is where I hit this problem first.   I changed the 
servlet so that it would accept http requests from localhost and  
the problem diminished but did not go away. 
 
The problem - I think - is in the org.apache.taglibs.io.PipiHelper 
class, in the pipe routine.  It currently reads:- 
 
            while (true) { 
                int size = input.read( buffer ); 
                if ( size <= 0 ) { 
                    return; 
                } 
                output.write( buffer, 0, size ); 
 
The problem is that size can be zero, especially for https 
sessions when the stream is not at end of file.  The only 
real end of file is when size == -1. 
 
The code should read:- 
 
            while (true) {  
                int size = input.read( buffer );  
                if ( size < 0 ) {  
                    return;  
                }  
                else if( size == 0)  { 
                        Thread.sleep( 1); 
                } 
                else { 
                         output.write( buffer, 0, size );  
                } 
 
I am not sure whether the Thread sleep is necessary, but it does 
give the scheduler a chance when the request is to a local source 
in the same process (i.e. to a Tomcat servlet).
Comment 1 Henri Yandell 2009-11-29 19:39:08 UTC
Resolving. Taglib has been retired.