Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-6635

Wrong message encoding for non-UTF systems

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.14.4
    • Fix Version/s: None
    • Component/s: STOMP
    • Labels:
      None
    • Environment:

      system where encoding not set to UTF-8 by default

    • Patch Info:
      Patch Available

      Description

      in StompConnection.java

      public void send(String destination, String message, String transaction, HashMap<String, String> headers) throws Exception {
              if (headers == null) {
                  headers = new HashMap<String, String>();
              }
              headers.put("destination", destination);
              if (transaction != null) {
                  headers.put("transaction", transaction);
              }
              StompFrame frame = new StompFrame("SEND", headers, message.getBytes());
              sendFrame(frame.format());
          }
      

      should be

      public void send(String destination, String message, String transaction, HashMap<String, String> headers) throws Exception {
              if (headers == null) {
                  headers = new HashMap<String, String>();
              }
              headers.put("destination", destination);
              if (transaction != null) {
                  headers.put("transaction", transaction);
              }
              StompFrame frame = new StompFrame("SEND", headers, message.getBytes("UTF-8"));
              sendFrame(frame.format());
          }
      

      or, at least if you use default encoding for converting here, you should use default encoding in StompFrame.format()

        Attachments

        1. StompConnection.patch
          0.2 kB
          Grigory Panov

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gpanov Grigory Panov
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: