Wrong char count in ServletOutputStream with non-ASCII characters skips content #18009
Labels
bug
This bug is not present in a released version of Open Liberty
Needs member attention
release bug
This bug is present in a released version of Open Liberty
release:21009
The ServletOutputStream skips the last chars when using
print
orprintln
to print content with multi-byte characters in UTF-8.The amount of chars skipped matches the difference between char count and byte count, on each
print
orprintln
.It doesn't matter whether it's done in the end of the response.
Changing to another encoding (e. g. ISO-8859-1) doesn't fix this.
No problem when using
write
instead ofprint
.No problem when using only ASCII characters.
No problem when using
PrintWriter response.getWriter()
.Steps to Reproduce
Get a
response.getOutputStream()
and print some text with non-ASCII content.On each
print
orprintln
, some characters will be skipped in the end.out.println("'ATENÇÃO!'"); // Skips last 2 characters
will print out:
'ATENÇÃO
A minimal web app is attached.
Expected behavior
It should print:
'ATENÇÃO!'
Diagnostic information:
Open Liberty 21.0.0.7
Additional context
This
s.length()
here may be the cause:open-liberty/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/response/WCOutputStream.java
Line 199 in 16559e1
bug.zip
Thanks @Thihup
The text was updated successfully, but these errors were encountered: