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

AbstractWebSocketSession.sendMessage race condition

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.2.5, 4.3 RC1
    • Fix Version/s: 4.2.6, 4.3 RC2
    • Component/s: Messaging:WebSocket
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      AbstractWebSocketSession.sendMessage() checks if the connection is still open via isOpen() and throws an IllegalArgumentException if not. However this does not guarantee that the connection will still be open by the time the underlying WS implementation actually tries to write. This means the caller still has to catch / handle the relevant IOException anyway.

      It is also impossible for the caller to avoid this exception as the remote side can close the connection at any time, so calling isOpen() before sendMessage() would suffer from exactly the same problem. The correct approach for this kind of situation is to simply attempt the IO operation and to let it fail naturally with an IOException in the underlying implementation if the connection has in fact been closed.

      So I suggest to completely remove the Assert.isTrue(isOpen(), ...); check.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            ksperling Karsten Sperling
            Last updater:
            Spring Issuemaster
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 40 weeks, 6 days ago