383304 Reset PrintWriter on response recycle

Backout changes based on jdk1.6 method and replace by nulling out AbstractHttpConnection._writer object.
This commit is contained in:
Jan Bartel 2012-07-19 20:14:41 +10:00
parent 999f66b6a8
commit 3c6a6fa8e0
3 changed files with 3 additions and 52 deletions

View File

@ -1,48 +0,0 @@
// ========================================================================
// Copyright (c) 2012-2012 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.io;
import java.io.PrintWriter;
import java.io.Writer;
/* ------------------------------------------------------------ */
/**
* ClearablePrintWriter
*
* Small class to make clearError method callable publically. Used for recycling the print writer on the response object.
*/
public abstract class ClearablePrintWriter extends PrintWriter
{
/* ------------------------------------------------------------ */
public ClearablePrintWriter(Writer writer, boolean autoFlush)
{
super(writer);
}
/* ------------------------------------------------------------ */
public ClearablePrintWriter(Writer writer)
{
super(writer);
}
/* ------------------------------------------------------------ */
public void clearError ()
{
super.clearError();
}
}

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.util.log.Logger;
* {@link java.io.IOException} thrown by the underlying implementation of
* {@link java.io.Writer} as {@link RuntimeIOException} instances.
*/
public class UncheckedPrintWriter extends ClearablePrintWriter
public class UncheckedPrintWriter extends PrintWriter
{
private static final Logger LOG = Log.getLogger(UncheckedPrintWriter.class);

View File

@ -362,7 +362,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
if (_server.isUncheckedPrintWriter())
_printWriter=new UncheckedPrintWriter(_writer);
else
_printWriter = new ClearablePrintWriter(_writer)
_printWriter = new PrintWriter(_writer)
{
public void close()
{
@ -402,8 +402,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
_responseFields.clear();
_response.recycle();
_uri.clear();
if (_printWriter != null && (_printWriter instanceof ClearablePrintWriter))
((ClearablePrintWriter)_printWriter).clearError();
_writer=null;
}
/* ------------------------------------------------------------ */