Author: markt Date: Wed Dec 19 09:48:06 2018 New Revision: 1849281 URL: http://svn.apache.org/viewvc?rev=1849281&view=rev Log: Ensure that the ServletOutputStream implementation is consistent with the requirements of asynchronous I/O and that all of the write methods use a single write rather than multiple writes.
Modified: tomcat/trunk/java/javax/servlet/ServletOutputStream.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/javax/servlet/ServletOutputStream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletOutputStream.java?rev=1849281&r1=1849280&r2=1849281&view=diff ============================================================================== --- tomcat/trunk/java/javax/servlet/ServletOutputStream.java (original) +++ tomcat/trunk/java/javax/servlet/ServletOutputStream.java Wed Dec 19 09:48:06 2018 @@ -55,9 +55,12 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void print(String s) throws IOException { - if (s == null) + if (s == null) { s = "null"; + } int len = s.length(); + byte[] buffer = new byte[len]; + for (int i = 0; i < len; i++) { char c = s.charAt(i); @@ -74,8 +77,9 @@ public abstract class ServletOutputStrea errMsg = MessageFormat.format(errMsg, errArgs); throw new CharConversionException(errMsg); } - write(c); + buffer[i] = (byte) (c & 0xFF); } + write(buffer); } /** @@ -182,8 +186,10 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(String s) throws IOException { - print(s); - println(); + StringBuilder sb = new StringBuilder(); + sb.append(s); + sb.append("\r\n"); + print(sb.toString()); } /** @@ -196,8 +202,14 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(boolean b) throws IOException { - print(b); - println(); + StringBuilder sb = new StringBuilder(); + if (b) { + sb.append(lStrings.getString("value.true")); + } else { + sb.append(lStrings.getString("value.false")); + } + sb.append("\r\n"); + print(sb.toString()); } /** @@ -210,8 +222,7 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(char c) throws IOException { - print(c); - println(); + println(String.valueOf(c)); } /** @@ -224,8 +235,7 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(int i) throws IOException { - print(i); - println(); + println(String.valueOf(i)); } /** @@ -238,8 +248,7 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(long l) throws IOException { - print(l); - println(); + println(String.valueOf(l)); } /** @@ -252,8 +261,7 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(float f) throws IOException { - print(f); - println(); + println(String.valueOf(f)); } /** @@ -266,8 +274,7 @@ public abstract class ServletOutputStrea * if an input or output exception occurred */ public void println(double d) throws IOException { - print(d); - println(); + println(String.valueOf(d)); } /** Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1849281&r1=1849280&r2=1849281&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Dec 19 09:48:06 2018 @@ -61,6 +61,11 @@ <code>HttpServlet</code> is relied upon to generate the HEAD response and the GET response uses chunking. (markt) </fix> + <fix> + Ensure that the <code>ServletOutputStream</code> implementation is + consistent with the requirements of asynchronous I/O and that all of the + write methods use a single write rather than multiple writes. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org