tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade HttpServletResponseFacade.java ServletWriterFacade.java
Date Tue, 27 Feb 2001 02:42:38 GMT
costin      01/02/26 18:42:38

  Modified:    src/facade22/org/apache/tomcat/facade
                        HttpServletResponseFacade.java
                        ServletWriterFacade.java
  Log:
  Another fix for the writer bug ( fixed by Nacho and Henri before M1 ).
  
  The new fix is reusing the writer, but makes sure close is not putting
  the PrintWriter in an un-usable state ( that was the original problem ).
  
  Nacho, Henri - please take a look ( I used jetspeed to reproduce and
  test and it seems the fix is good )
  
  Revision  Changes    Path
  1.18      +4 -21     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java
  
  Index: HttpServletResponseFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- HttpServletResponseFacade.java	2001/02/20 03:34:10	1.17
  +++ HttpServletResponseFacade.java	2001/02/27 02:42:38	1.18
  @@ -88,20 +88,20 @@
       private boolean usingStream = false;
       private boolean usingWriter = false;
       ServletOutputStreamFacade osFacade=null;
  -    PrintWriter writer = null; // XXX will go away when we add the convertor
  +    ServletWriterFacade writer;
   
  -    // Logger.Helper loghelper = new Logger.Helper("tc_log", "HttpServletResponseFacade");
   
  -    
       /** Package
        */
       HttpServletResponseFacade(Response response) {
           this.response = response;
  +	OutputBuffer oBuffer= response.getBuffer();
  +	writer = new ServletWriterFacade( oBuffer, response);
       }
   
       void recycle() {
   	usingStream = false;
   	usingWriter= false;
  -	writer=null; // no need - the OutputBuffer will deal with enc
  +	//	writer=null; // fixed ( ? )
   	if( osFacade != null ) osFacade.recycle();
       }
   
  @@ -193,23 +193,6 @@
   	    throw new IllegalStateException(msg);
   	}
   	usingWriter= true ;
  -	// 	response.setUsingWriter( true );
  -
  -	// old mechanism
  -	// if( osFacade==null && response.getOutputBuffer() == null )
  -	// 	    return response.getWriter();
  -
  -	if( writer != null ) return writer;
  -	if(  osFacade == null ) {
  -	    osFacade=new ServletOutputStreamFacade(response);
  -	}
  -
  -	OutputBuffer oBuffer= response.getBuffer();
  -	writer = new ServletWriterFacade( oBuffer, response);
  -	
  -	// writer=((ResponseImpl)response).getWriter( osFacade );
  -	// 	response.setServletOutputStream( osFacade );
  -	// 	response.setWriter(  writer );
   
   	return writer;
       }
  
  
  
  1.4       +10 -0     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletWriterFacade.java
  
  Index: ServletWriterFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletWriterFacade.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServletWriterFacade.java	2001/02/20 03:34:11	1.3
  +++ ServletWriterFacade.java	2001/02/27 02:42:38	1.4
  @@ -110,6 +110,16 @@
   	super.write( str );
       }
   
  +    public void close() {
  +	// We don't close the PrintWriter - super() is not called,
  +	// so the stream can be reused. We close ob.
  +	try {
  +	    ob.close();
  +	} catch (IOException ex ) {
  +	    ex.printStackTrace();
  +	}
  +    }
  +    
       /** Reuse the object instance, avoid GC
        *  Called from BSOS
        */
  
  
  

Mime
View raw message