Hi!
In the process of implementing error handling on my websocket, I am trying
to send proper error messages to the client in case the format is incorrect.
The idea is that I publish the spec of my websocket, I have no control of
who implements what client, so I need to cover the error cases as well.
My expectation is that, for each DecodeException, my @OnError is called so
that I can properly wire the exception handling. Instead, I am noticing that
the DecodeExceptions thrown by the decoders seems to be disappear in the
framework. Looking at the code, EndpointWrapper:
https://java.net/projects/tyrus/sources/source-code-repository/content/trunk
/core/src/main/java/org/glassfish/tyrus/core/EndpointWrapper.java?rev=762
calls the decoder, and just adds the exceptions to the ErrorCollector:
https://java.net/projects/tyrus/sources/source-code-repository/content/trunk
/core/src/main/java/org/glassfish/tyrus/core/ErrorCollector.java?rev=762
After that, I do not see that they result in notifications on the
WSEndpoint. As of now, they seem to be silently ignored (unless you turn on
the logging), which I don't feel is right.
Here:
https://docs.oracle.com/javaee/7/api/javax/websocket/Endpoint.html#onError%2
8javax.websocket.Session,%20java.lang.Throwable%29
says one type of errors are "conversion errors encoding incoming messages
before any message handler has been called. These are modeled as
DecodeExceptions". Which seems to suggest my expectation was right. But I am
not sure.
As a workaround, I am creating the decoder myself, hooking it up to the
@OnOpen/_at_OnMessage/_at_OnClose. It works, but it's less than ideal.
Should I consider this behavior a bug (and report it as such)? Or is it
intended?
Thanks!
Gabriele