Author: markt
Date: Mon Dec 24 21:07:01 2012
New Revision: 1425680
URL: http://svn.apache.org/viewvc?rev=1425680&view=rev
Log:
Text messages are always UTF8
(Note that even with this fix Autobahn identifies a lot of UTF-8 handling
issues. The quick and dirty new String() approach needs a more robust
replacement.)
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java?rev=1425680&r1=1425679&r2=1425680&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java Mon Dec 24
21:07:01 2012
@@ -18,6 +18,7 @@ package org.apache.tomcat.websocket;
import java.io.EOFException;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import javax.servlet.ServletInputStream;
@@ -282,8 +283,13 @@ public class WsFrame {
@SuppressWarnings("unchecked")
private void sendMessage(boolean last) {
if (textMessage) {
- String payload =
- new String(messageBuffer.array(), 0,
messageBuffer.limit());
+ String payload = null;
+ try {
+ payload = new String(messageBuffer.array(), 0,
+ messageBuffer.limit(), "UTF8");
+ } catch (UnsupportedEncodingException e) {
+ // All JVMs must support UTF8
+ }
MessageHandler mh = wsSession.getTextMessageHandler();
if (mh != null) {
if (mh instanceof MessageHandler.Async<?>) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]