jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

javax websocket decoders - parameter types do not match after reorder

Open lachlan-roberts opened this issue 5 years ago • 6 comments

Jetty version 10.0.x

Description If a decoder decodes into a subtype of what is defined in the onMessage method, then an IllegalArgumentException is thrown when the endpoint is added. An example of a setup which would trigger this is:

@ServerEndpoint(value = "/", decoders = StringWrapperDecoder.class)
public static class DecoderServerEndpoint
{
    @OnMessage
    public String onMessage(StringWrapper message)
    {
        return message.getString();
    }
}

public static class StringWrapperDecoder implements Decoder.Text<StringWrapperExtension>{...}

public static class StringWrapper{...}

public static class StringWrapperExtension extends StringWrapper{...}

Stacktrace:

java.lang.IllegalArgumentException: parameter types do not match after reorder: (DecoderServerEndpoint,StringWrapper,Session)String, (DecoderServerEndpoint,Session,StringWrapperExtension)String
	at java.base/java.lang.invoke.MethodHandleStatics.newIllegalArgumentException(MethodHandleStatics.java:129)
	at java.base/java.lang.invoke.MethodHandles.permuteArgumentChecks(MethodHandles.java:3321)
	at java.base/java.lang.invoke.MethodHandles.permuteArguments(MethodHandles.java:3188)
	at org.eclipse.jetty.websocket.util.InvokerUtils.mutatedInvoker(InvokerUtils.java:419)
	at org.eclipse.jetty.websocket.util.InvokerUtils.optionalMutatedInvoker(InvokerUtils.java:458)
	at org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory.lambda$discoverJavaxFrameHandlerMetadata$0(JavaxWebSocketFrameHandlerFactory.java:471)
	at org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory.matchDecoders(JavaxWebSocketFrameHandlerFactory.java:611)
	at org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory.discoverJavaxFrameHandlerMetadata(JavaxWebSocketFrameHandlerFactory.java:474)
	at org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerFrameHandlerFactory.getMetadata(JavaxWebSocketServerFrameHandlerFactory.java:58)
	at org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerContainer.addEndpointMapping(JavaxWebSocketServerContainer.java:230)
	at org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerContainer.addEndpoint(JavaxWebSocketServerContainer.java:179)
	at org.eclipse.jetty.websocket.javax.tests.coders.ExtendedDecoderTest.lambda$before$0(ExtendedDecoderTest.java:61)
	at org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer.lambda$configure$0(JavaxWebSocketServletContainerInitializer.java:115)
	at org.eclipse.jetty.servlet.listener.ContainerInitializer$ServletContainerInitializerServletContextListener.contextInitialized(ContainerInitializer.java:142)
	at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:961)
        ...

lachlan-roberts avatar May 28 '20 04:05 lachlan-roberts

@joakime do you think is this something that we actually need to support? it doesn't mention anything about situations like this in the JSR.

lachlan-roberts avatar May 29 '20 05:05 lachlan-roberts

Not sure if this is supported (or not). I'll have to reread the spec.

joakime avatar Sep 25 '20 15:09 joakime

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 27 '22 00:02 github-actions[bot]

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 01 '23 00:03 github-actions[bot]

This issue has been closed due to it having no activity.

github-actions[bot] avatar Apr 02 '23 00:04 github-actions[bot]

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 02 '24 00:04 github-actions[bot]

Closing as no one has reported this to be an issue for them.

lachlan-roberts avatar May 27 '24 11:05 lachlan-roberts