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

Class inheritance issue in websocket Encoder

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0.Beta33
    • None
    • None
    • None

      Steps to reproduce:

      1) Create two classes (POJOs): ClassA and ClassB with ClassB being a subclass of ClassA so ClassB extends ClassA.

      2) Create an encoder for ClassA so that:
      ClassAEncoder implements Encoder.Text<ClassA>

      {....}

      3) Specify this encoder on your @ServerEndpoint so that:
      @ServerEndpoint(......., encoders =

      { ClassAEncoder.class }

      ,....)

      4) Now try to send an instance of ClassB like:
      ClassB classBInstance = new ClassB();
      session.getBasicRemote().sendObject(classBInstance);

      You should get the following exception:
      "...javax.websocket.EncodeException: No suitable encoder found"

      If you create an Encoder for ClassB then obviously everything is working fine..

      The specification doesn't seem to say much about inheritance support in Encoders so I'm assuming implementations have the freedom to either support this or not?

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              savvas.andreas_jira Savvas Andreas Moysidis (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: