You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a client connects with sub-protocol "fst", we see that the configurator is hit, and correctly sets "fst" as a "subprotocol" property on the user properties.
Subsequently, a breakpoint on line 5 shows that the decoder is constructed from DecoderFactory, and that init(EndpointConfig) is called whereby the subprotocol is obtained (fst) and a delegate decoder is constructed (line 12). Everything appears fine at this point.
However, next the breakpoint on line 5 is hit again, this time from OnMessageCallable. For this new instance init(EndpointConfig) is never called. Subsequently, our breakpoint at line 19 is hit, invoked against this new instance that has no delegate set, resulting in an NPE.
The JavaDoc for javax.websocket.Decoder states:
/* The websocket implementation creates a new instance of the decoder per endpoint instance
* per connection. The lifecycle of the Decoder instance is governed by the container calls to
* the Decoder.init(javax.websocket.EndpointConfig) and Decoder.destroy() methods.
Jetty does appear to be constructing a new instance "per endpoint instance" and "per connection", however, this instance is never used AFAICT. Instead, a new instance is being constructed, and its lifecycle methods never called, resulting in an NPE.
It seems clear that because the init() method accepts an EndpointConfig, from which user properties are available, the intention is that each En/Decoder instance should share the same "session" as was available in the Configurator.modifyHandshake(ServerEndpointConfig config) invocation.
The text was updated successfully, but these errors were encountered:
I have a server endpoint defined as follows:
The
ServerEventConfigurator
configurator sets the negotiated protocol as a user property (hackish because of #424):Finally, the decoder (
SubprotoDecoderDelegator
) with line numbers for commentary below:When a client connects with sub-protocol "fst", we see that the configurator is hit, and correctly sets "fst" as a "subprotocol" property on the user properties.
Subsequently, a breakpoint on line 5 shows that the decoder is constructed from DecoderFactory, and that
init(EndpointConfig)
is called whereby the subprotocol is obtained (fst) and a delegate decoder is constructed (line 12). Everything appears fine at this point.However, next the breakpoint on line 5 is hit again, this time from OnMessageCallable. For this new instance
init(EndpointConfig)
is never called. Subsequently, our breakpoint at line 19 is hit, invoked against this new instance that has no delegate set, resulting in an NPE.The JavaDoc for
javax.websocket.Decoder
states:Jetty does appear to be constructing a new instance "per endpoint instance" and "per connection", however, this instance is never used AFAICT. Instead, a new instance is being constructed, and its lifecycle methods never called, resulting in an NPE.
It seems clear that because the
init()
method accepts anEndpointConfig
, from which user properties are available, the intention is that each En/Decoder instance should share the same "session" as was available in theConfigurator.modifyHandshake(ServerEndpointConfig config)
invocation.The text was updated successfully, but these errors were encountered: