[jboss-jira] [JBoss JIRA] (WFLY-3254) Wildfly unable to register websocket endpoint if there is a lambda in its code
Stuart Douglas (JIRA)
issues at jboss.org
Wed Apr 16 03:22:33 EDT 2014
[ https://issues.jboss.org/browse/WFLY-3254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12962186#comment-12962186 ]
Stuart Douglas commented on WFLY-3254:
--------------------------------------
I have applied a fix to undertow upstream that will allow the second form to work (i.e. when you define an interface that extends MessageHandler.Whole<String>). I don't think it is possible to make the first form work, as no generic type information is preserved, so there is no way to tell what type of object the lambda is expecting.
> Wildfly unable to register websocket endpoint if there is a lambda in its code
> ------------------------------------------------------------------------------
>
> Key: WFLY-3254
> URL: https://issues.jboss.org/browse/WFLY-3254
> Project: WildFly
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Web (Undertow)
> Affects Versions: 8.0.0.Final
> Reporter: Viktor Gamov
> Assignee: Stuart Douglas
>
> Trying to programmatically register WebSocket endpoint with following code
> {code:java}
> public class BidEndpointApi extends Endpoint {
> @Override
> public void onClose(Session session, CloseReason closeReason) {
> System.err.println("Closing: " + closeReason.getReasonPhrase());
> }
> @Override
> public void onError(Session session, Throwable t) {
> System.err.println("Error: " + t.getLocalizedMessage());
> }
> @Override public void onOpen(Session session, EndpointConfig config) {
> final Session mySession = session;
> session.addMessageHandler((MessageHandler.Whole<String>) message -> {
> try {
> mySession.getBasicRemote().sendText(
> "[Server speaking]: Got your message" + message + "Sending it back to you");
> } catch (IOException e) {
> e.printStackTrace();
> }
> });
> }
> }
> {code}
> Application starts and operates normally but when I try to hit this websocket endpoint from JavaScript client getting following server-side exception
> {code}
> [31m02:46:56,438 ERROR [io.undertow.request] (default task-9) Blocking request failed HttpServerExchange{ GET /auction_jaxrs-1.0/bidprog}: java.lang.IllegalStateException: UT003007: Unable to detect MessageHandler type for class com.farata.course.mwd.auction.websocket.BidEndpointApi$$Lambda$1/662246937
> at io.undertow.websockets.jsr.util.ClassUtils.getHandlerTypes(ClassUtils.java:64)
> at io.undertow.websockets.jsr.FrameHandler.addHandler(FrameHandler.java:328)
> at io.undertow.websockets.jsr.UndertowSession.addMessageHandler(UndertowSession.java:99)
> at com.farata.course.mwd.auction.websocket.BidEndpointApi.onOpen(BidEndpointApi.java:25)
> at io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:81)
> at io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
> at io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:244)
> at io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:218)
> at io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1090)
> at io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1310)
> at io.undertow.server.Connectors.terminateResponse(Connectors.java:69)
> at io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
> at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:249)
> at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:183)
> at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162) [xnio-api-3.2.0.Final.jar:3.2.0.Final]
> at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
> at org.xnio.channels.Channels.flushBlocking(Channels.java:63) [xnio-api-3.2.0.Final.jar:3.2.0.Final]
> at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:623)
> at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
> at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
> at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
> at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168)
> at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0]
> at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
> {code}
> Environment banner
> ========================================================================
> JBoss Bootstrap Environment
> JBOSS_HOME: /Users/apple/projects/screencast2/wildfly-8.0.0.Final
> JAVA: /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java
> JAVA_OPTS: -server -XX:+UseCompressedOops -Djboss.bind.address.management=127.0.0.1
> =========================================================================
> Have no problems with Anonymous class
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list