activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Achim Gmeiner (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (AMQ-2684) Incorrect character encoding/decoding when using websocket/stomp transport
Date Tue, 06 Apr 2010 10:53:08 GMT

     [ https://issues.apache.org/activemq/browse/AMQ-2684?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Achim Gmeiner reopened AMQ-2684:
--------------------------------


I guess character encoding should also be specified for the StompFrame.getBody() method to
keep everything consistent.

 StompFrame.java
{noformat}
    public String getBody() {
        try {
            return new String(content, "UTF-8");
        } catch (Throwable e) {			
            return Arrays.toString(getContent());
        }
    }
{noformat}


> Incorrect character encoding/decoding when using websocket/stomp transport
> --------------------------------------------------------------------------
>
>                 Key: AMQ-2684
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2684
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Transport
>    Affects Versions: 5.4.0
>         Environment: Windows 7 64bit
> Java 1.6.0_18
>            Reporter: Achim Gmeiner
>            Assignee: Dejan Bosanac
>             Fix For: 5.4.0
>
>         Attachments: StompFrame.java, StompSocket.java
>
>
> Non ANSI-characters sent over the websocket/stomp transport are not encoded/decoded correctly.
In my case client and server are using UTF-8 for character encoding. 
> Changing StompSocket.onMessage(byte frame, String data) to
> {noformat}
>   public void onMessage(byte frame, String data) {}
>        try {
>             protocolConverter.onStompCommand((StompFrame)wireFormat.unmarshal(new ByteSequence(data.getBytes("UTF-8"))));
>        } catch (Exception e) {
>             onException(IOExceptionSupport.create(e));
>        }
>    }
> {noformat}
> and StompFrame.toString() to
> {noformat}
>   public String toString() {
>         StringBuffer buffer = new StringBuffer();
>         buffer.append(getAction());
>         buffer.append("\n");
>         Map headers = getHeaders();
>         for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
>             Map.Entry entry = (Map.Entry)iter.next();
>             buffer.append(entry.getKey());
>             buffer.append(":");
>             buffer.append(entry.getValue());
>             buffer.append("\n");
>         }
>         buffer.append("\n");
>         if (getContent() != null) {
>             try {
>                 buffer.append(new String(getContent(), "UTF-8"));
>             } catch (Throwable e) {
>                 buffer.append(Arrays.toString(getContent()));
>             }
>         }
>         return buffer.toString();
>     }
> {noformat}
> solved the problem for me. The changes are minor, I only specified the encoding when
reading bytes arrays. 
> Maybe there should be a way to configure the encoding to be used...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message