Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-287

Generics issue with WebSocket de-/encoders

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Done
    • None
    • 1.1.Beta7
    • None
    • None

    Description

      http://java.dzone.com/articles/using-java-websockets-jsr-356
      This example of WebSocket de-/encoders won't work in WildFly. I get this exception:

      javax.websocket.DeploymentException: UT003029: Could not find message parameter on method public void SomeClass.someMethod(SomeMessageType)

      As far as I can tell, this is due to a wrong/different implementation in Undertow. Apparently, other application servers handle these cases differently (though I did not test that!), because the tutorial linked above would not exist otherwise.

      The problem is the way of determining the type that a de-/encoder handles. In order to do that, Undertow uses the parameter type of the first parameter of the encode/decode method:
      https://github.com/undertow-io/undertow/blob/master/websockets-jsr/src/main/java/io/undertow/websockets/jsr/EncodingFactory.java#L263

      That won't work if that parameter is generic, because type erasure will turn it into "Object", so that there are plenty of de-/encoders for "Object" registered in the EncodingFactory, but none for the types I need.

      The Tyrus reference implementation on the other hand uses a complicated method to retrieve the value from the generic type parameter:
      https://github.com/tyrus-project/tyrus/blob/a43ba3af79208048787f4b1706c94379d3f26955/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java#L355
      https://github.com/tyrus-project/tyrus/blob/a43ba3af79208048787f4b1706c94379d3f26955/core/src/main/java/org/glassfish/tyrus/core/ReflectionHelper.java

      This issue is similar to UNDERTOW-166.

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            philipp91 Philipp Keck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: