jakartaee / jakartaee/websocket
Clarify search order of Encoders / Decoders
- Dominant language
- Java
- Stars
- 78
- Forks
- 47
- Avg merge
- 1h 32m
- Merged PRs (30d)
- 1
Description
As outlined in https://github.com/eclipse-ee4j/websocket-api/issues/39#issuecomment-364855086 ...
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)?
``` java
@ServerEndpoint(
value = "/purchase",
decoders = {AppleDecoder.class, PearDecoder.class, FruitDecoder.class},
configurator = FruitStandConfigurator.class
)
public class PurchaseEndpoint
{
}
```
and in the container init ...
``` java
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)
Contributor guide
Research direction
Start with the linked issue comment and the annotation and ServerEndpointConfig examples in this issue. Determine how developer-provided decoders from annotations and configuration are combined, and whether platform decoder order matters. Done means the WebSocket specification clearly states one resulting search order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100