Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2758

No enum constant exception in STOMP protocol

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Optional Optional
    • 5.3.3, 5.2.22
    • 5.3.1
    • False
    • None
    • False
    • Moderate

      Frequently but not every time, when a client connects to the STOMP server, an exception is thrown:

      SEVERE: JGRP000236: failure reading frame java.lang.IllegalArgumentException: No enum constant org.jgroups.protocols.STOMP.ServerVerb. at java.base/java.lang.Enum.valueOf(Enum.java:240) at org.jgroups.protocols.STOMP$ServerVerb.valueOf(STOMP.java:88) at org.jgroups.client.StompConnection.run(StompConnection.java:292) at java.base/java.lang.Thread.run(Thread.java:829)

      Root Cause:

      When a client connects to the STOMP server, two frames need to be sent. One is the INFO packet (if send_info is enabled) and the other is the CONNECTED frame.

      Both of these frames are sent from the writeResponse method on line 527. However, these two frames are sent from two different threads resulting in a concurrency issue. The main stomp thread sends INFO, while the connection's thread sends the CONNECTED response. Since access to writing the response is not synchronized, both frames are built in parallel and submitted to the socket's output stream around the same time.

      The data from the two frames get intermingled in an indeterminate way, with the two end-of-frame null characters ending up in different places, resulting in invalid frames being sent.

      Fortunately this is easy to fix. Making writeResponse a synchronized method fixed the issue, resulting in the full frame being built and sent in sequence instead of being intermingled. Perhaps a smaller synchronized block would also suffice rather than synchronizing the whole method.

              rhn-engineering-bban Bela Ban
              kmcweeny Ken McWeeny (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: