Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-12307

TextMessage.toString() throws StringIndexOutOfBoundsException if payload contains multibyte characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.0.7, 4.1.1
    • Fix Version/s: 4.0.8, 4.1.2
    • Component/s: Messaging:WebSocket
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      TextMessage.toStringPayload throws StringIndexOutOfBoundsException if a payload-bytes is greater than 10 and a payload-length less than 10.
      This method throws an exception in the following code.

      new TextMessage("\u3042\u3044\u3046\u3048\u304a").toString();
      

      Stacktrace:
      Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 10
      at java.lang.String.substring(String.java:1950)
      at org.springframework.web.socket.TextMessage.toStringPayload(TextMessage.java:79)
      at org.springframework.web.socket.AbstractWebSocketMessage.toString(AbstractWebSocketMessage.java:91)
      at samples.websocket.config.SampleWebSocketsApplication.main(SampleWebSocketsApplication.java:58)

      Pull request:
      https://github.com/spring-projects/spring-framework/pull/657

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            emalock3 Shinobu Aoki
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 30 weeks, 1 day ago