Skip to content

Clarify search order of Encoders / Decoders #289

@joakime

Description

@joakime

As outlined in #39 (comment) ...

Danny Coward states ...

then try to find a Decoder.Text or a Decoder.TextStream. Look, in order, through developer provided ones (single list, may contain both Text and TextStream types). Then look through platform provided ones. Use the first match to decode it. If the decode works, call the MessageHandler and stop, if not, call the onError/@websocket method with the decode exception and stop.

What is the search order when the "developer provided ones" comes from 2 places (annotations and configuration)?

@ServerEndpoint(
    value = "/purchase",
    decoders = {AppleDecoder.class, PearDecoder.class, FruitDecoder.class},
    configurator = FruitStandConfigurator.class
)
public class PurchaseEndpoint
{
}

and in the container init ...

        ServerContainer container = servletContext.getAttribuet(javax.websocket.server.ServerContainer.class.getName());
        ServerEndpointConfig config = ServerEndpointConfig.Builder.create(PurchaseEndpoint.class, "/floo")
                .decoders(Arrays.asList(CherryDecoder.class, BananaDecoder.class)).build();
        container.addEndpoint(config);

What is the resulting search order of decoders?

Option 1: (EndpointConfig wins over Annotations)

  1. CherryDecoder.class
  2. BananaDecoder.class
  3. AppleDecoder.class
  4. PearDecoder.class
  5. FruitDecoder.class
  6. Platform Provided Decoders

Option 2: (Annotation wins over EndpointConfig)

  1. AppleDecoder.class
  2. PearDecoder.class
  3. FruitDecoder.class
  4. CherryDecoder.class
  5. BananaDecoder.class
  6. Platform Provided Decoders

(Does the order of the Platform Decoders matter? I don't think so)

Metadata

Metadata

Assignees

No one assigned

    Labels

    API (Both)Impacts the client and server APIenhancementAdding a new feature or improving an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions