remm 02/03/31 11:27:08
Modified: jasper2/src/share/org/apache/jasper/runtime
JspWriterImpl.java
Log:
- Synchronization of the writer doesn't seem to be useful (for the same reason
the response writer isn't synced).
Revision Changes Path
1.3 +119 -154
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java
Index: JspWriterImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JspWriterImpl.java 31 Mar 2002 09:02:52 -0000 1.2
+++ JspWriterImpl.java 31 Mar 2002 19:27:08 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v
1.2 2002/03/31 09:02:52 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2002/03/31 09:02:52 $
+ * $Header:
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v
1.3 2002/03/31 19:27:08 remm Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/03/31 19:27:08 $
*
* ====================================================================
*
@@ -157,17 +157,15 @@
* may be invoked by PrintStream.
*/
protected final void flushBuffer() throws IOException {
- synchronized (lock) {
- if (bufferSize == 0)
- return;
- flushed = true;
- ensureOpen();
- if (nextChar == 0)
- return;
- initOut();
- out.write(cb, 0, nextChar);
- nextChar = 0;
- }
+ if (bufferSize == 0)
+ return;
+ flushed = true;
+ ensureOpen();
+ if (nextChar == 0)
+ return;
+ initOut();
+ out.write(cb, 0, nextChar);
+ nextChar = 0;
}
protected void initOut() throws IOException {
@@ -182,23 +180,19 @@
* Discard the output buffer.
*/
public final void clear() throws IOException {
- synchronized (lock) {
- if (bufferSize == 0)
- throw new
IllegalStateException(Constants.getString("jsp.error.ise_on_clear"));
- if (flushed)
- throw new
IOException(Constants.getString("jsp.error.attempt_to_clear_flushed_buffer"));
- ensureOpen();
- nextChar = 0;
- }
+ if (bufferSize == 0)
+ throw new
IllegalStateException(Constants.getString("jsp.error.ise_on_clear"));
+ if (flushed)
+ throw new
IOException(Constants.getString("jsp.error.attempt_to_clear_flushed_buffer"));
+ ensureOpen();
+ nextChar = 0;
}
public void clearBuffer() throws IOException {
- synchronized (lock) {
- if (bufferSize == 0)
- throw new
IllegalStateException(Constants.getString("jsp.error.ise_on_clear"));
- ensureOpen();
- nextChar = 0;
- }
+ if (bufferSize == 0)
+ throw new
IllegalStateException(Constants.getString("jsp.error.ise_on_clear"));
+ ensureOpen();
+ nextChar = 0;
}
private final void bufferOverflow() throws IOException {
@@ -210,13 +204,11 @@
*
*/
public void flush() throws IOException {
- synchronized (lock) {
- flushBuffer();
- if (out != null) {
- out.flush();
- // Also flush the response buffer.
- response.flushBuffer();
- }
+ flushBuffer();
+ if (out != null) {
+ out.flush();
+ // Also flush the response buffer.
+ response.flushBuffer();
}
}
@@ -225,17 +217,15 @@
*
*/
public void close() throws IOException {
- synchronized (lock) {
- if (response == null || closed)
- // multiple calls to close is OK
- return;
- flush();
- if (out != null)
- out.close();
- out = null;
- closed = true;
- // cb = null;
- }
+ if (response == null || closed)
+ // multiple calls to close is OK
+ return;
+ flush();
+ if (out != null)
+ out.close();
+ out = null;
+ closed = true;
+ // cb = null;
}
/**
@@ -257,20 +247,18 @@
*
*/
public void write(int c) throws IOException {
- synchronized (lock) {
- ensureOpen();
- if (bufferSize == 0) {
- initOut();
- out.write(c);
- }
- else {
- if (nextChar >= bufferSize)
- if (autoFlush)
- flushBuffer();
- else
- bufferOverflow();
- cb[nextChar++] = (char) c;
- }
+ ensureOpen();
+ if (bufferSize == 0) {
+ initOut();
+ out.write(c);
+ }
+ else {
+ if (nextChar >= bufferSize)
+ if (autoFlush)
+ flushBuffer();
+ else
+ bufferOverflow();
+ cb[nextChar++] = (char) c;
}
}
@@ -301,48 +289,47 @@
public void write(char cbuf[], int off, int len)
throws IOException
{
- synchronized (lock) {
- ensureOpen();
+ ensureOpen();
+
+ if (bufferSize == 0) {
+ initOut();
+ out.write(cbuf, off, len);
+ return;
+ }
- if (bufferSize == 0) {
- initOut();
- out.write(cbuf, off, len);
- return;
- }
-
- if ((off < 0) || (off > cbuf.length) || (len < 0) ||
- ((off + len) > cbuf.length) || ((off + len) < 0)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
-
- if (len >= bufferSize) {
- /* If the request length exceeds the size of the output buffer,
- flush the buffer and then write the data directly. In this
- way buffered streams will cascade harmlessly. */
+ if ((off < 0) || (off > cbuf.length) || (len < 0) ||
+ ((off + len) > cbuf.length) || ((off + len) < 0)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
+ }
+
+ if (len >= bufferSize) {
+ /* If the request length exceeds the size of the output buffer,
+ flush the buffer and then write the data directly. In this
+ way buffered streams will cascade harmlessly. */
+ if (autoFlush)
+ flushBuffer();
+ else
+ bufferOverflow();
+ initOut();
+ out.write(cbuf, off, len);
+ return;
+ }
+
+ int b = off, t = off + len;
+ while (b < t) {
+ int d = min(bufferSize - nextChar, t - b);
+ System.arraycopy(cbuf, b, cb, nextChar, d);
+ b += d;
+ nextChar += d;
+ if (nextChar >= bufferSize)
if (autoFlush)
flushBuffer();
else
bufferOverflow();
- initOut();
- out.write(cbuf, off, len);
- return;
- }
-
- int b = off, t = off + len;
- while (b < t) {
- int d = min(bufferSize - nextChar, t - b);
- System.arraycopy(cbuf, b, cb, nextChar, d);
- b += d;
- nextChar += d;
- if (nextChar >= bufferSize)
- if (autoFlush)
- flushBuffer();
- else
- bufferOverflow();
- }
}
+
}
/**
@@ -362,25 +349,23 @@
*
*/
public void write(String s, int off, int len) throws IOException {
- synchronized (lock) {
- ensureOpen();
- if (bufferSize == 0) {
- initOut();
- out.write(s, off, len);
- return;
- }
- int b = off, t = off + len;
- while (b < t) {
- int d = min(bufferSize - nextChar, t - b);
- s.getChars(b, b + d, cb, nextChar);
- b += d;
- nextChar += d;
- if (nextChar >= bufferSize)
- if (autoFlush)
- flushBuffer();
- else
- bufferOverflow();
- }
+ ensureOpen();
+ if (bufferSize == 0) {
+ initOut();
+ out.write(s, off, len);
+ return;
+ }
+ int b = off, t = off + len;
+ while (b < t) {
+ int d = min(bufferSize - nextChar, t - b);
+ s.getChars(b, b + d, cb, nextChar);
+ b += d;
+ nextChar += d;
+ if (nextChar >= bufferSize)
+ if (autoFlush)
+ flushBuffer();
+ else
+ bufferOverflow();
}
}
@@ -404,9 +389,7 @@
*/
public void newLine() throws IOException {
- synchronized (lock) {
- write(lineSeparator);
- }
+ write(lineSeparator);
}
@@ -554,10 +537,8 @@
* <code>{@link #println()}</code>.
*/
public void println(boolean x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -566,10 +547,8 @@
* #println()}</code>.
*/
public void println(char x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -578,10 +557,8 @@
* #println()}</code>.
*/
public void println(int x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -590,10 +567,8 @@
* <code>{@link #println()}</code>.
*/
public void println(long x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -602,10 +577,8 @@
* <code>{@link #println()}</code>.
*/
public void println(float x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -614,10 +587,8 @@
* #print(double)}</code> and then <code>{@link #println()}</code>.
*/
public void println(double x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -626,10 +597,8 @@
* <code>{@link #println()}</code>.
*/
public void println(char x[]) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -638,10 +607,8 @@
* <code>{@link #println()}</code>.
*/
public void println(String x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
/**
@@ -650,10 +617,8 @@
* <code>{@link #println()}</code>.
*/
public void println(Object x) throws IOException {
- synchronized (lock) {
- print(x);
- println();
- }
+ print(x);
+ println();
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>