When a @ServerEndpoint
@OnMessage
handler throw a RuntimeException
, the JSR-356 implementation Undertow (used in WildFly) force-close the endpoint and doesn’t even call the @OnClose
method. Undertow then call the @OnError
method. But at this point in time, the application code can no longer recover or handle the exception. This practice violate the JSR-356 specification and effectively kill Java exception programming. GlassFish with his Tyrus implementation work like a charm, at least in this context. Otherwise, I must say WildFly outperform GlassFish in almost all other ways.
Filed a bug here: https://issues.jboss.org/browse/UNDERTOW-284
Wrote a test application here (the repository’s README.md file offer a workaround): https://github.com/MartinanderssonDotcom/websocket-exception-handling