Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct examples using string.getBytes() without a charset #53

Closed
andreho opened this issue May 13, 2015 · 2 comments
Closed

Correct examples using string.getBytes() without a charset #53

andreho opened this issue May 13, 2015 · 2 comments

Comments

@andreho
Copy link
Contributor

andreho commented May 13, 2015

Hi,
there is a problem in your Java examples, that obtain an encoded content of a string as a byte-array via java.lang.String.getBytes():byte[] method. This may lead to a poison message, which makes your whole queue not readable and results in an error (bad_utf8_character_code) looking like this example:

=ERROR REPORT==== 7-May-2015::15:59:37 ===
** Handler sockjs_cowboy_handler terminating in websocket_info/3
   for the reason exit:{ucs,{bad_utf8_character_code}}
** Message was go
** Options were {service,"/stomp",#Fun<rabbit_ws_sockjs.1.120271989>,{},
                         "http://cdn.sockjs.org/sockjs-0.2.js",false,true,
                         5000,25000,131072,#Fun<rabbit_ws_sockjs.0.116551930>,
                         undefined}

.... and so on.

The call of string.getBytes() method uses by default "Charset.defaultCharset()" or "ISO-8859-1" which could produce an incompatible byte-sequence and make it impossible to retrive a queued message.

We would advice to change all calls of string.getBytes() to string.getBytes("UTF-8") in existing examples to force usage of a compatible string encoding.

How to reproduce: publish a message with the following content "Läuft alles?" into a queue using your examples and then try to retrieve this message.

Debian, RabbitMQ 3.5.1, SockJS + Stomp
Greetz, Andre.

@michaelklishin
Copy link
Member

@andreho feel free to submit a pull request.

@andreho
Copy link
Contributor Author

andreho commented May 19, 2015

Thx ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants