You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sebastien <se...@gmail.com> on 2014/10/10 17:09:13 UTC

[7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Hi,

Using 7.0.0-SNAPSHOT, I've got a UnsupportedOperationException (see below)
whereas I do not have it on 7.0.0-M3. I don't really know how to
investigate as an UnsupportedOperationException seems to be the expected
result [1], or maybe #sendError is not supposed to be called anyway, or it
is a regression from -M3...

I'm using wicket-native-websocket-core & wicket-native-websocket-javax on
WildFly8

Thanks in advance for your advise,
Sebastien.

[1]
https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketResponse.java#L193

--
ERROR [org.apache.wicket.request.cycle.RequestCycle] Error during
processing error message: java.lang.UnsupportedOperationException
        at
org.apache.wicket.protocol.ws.api.WebSocketResponse.sendError(WebSocketResponse.java:193)
[wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77)
[wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
[wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:314)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:237)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
[wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:219)
[wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.onConnect(AbstractWebSocketProcessor.java:150)
[wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.protocol.ws.javax.JavaxWebSocketProcessor.<init>(JavaxWebSocketProcessor.java:48)
[wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
org.apache.wicket.protocol.ws.javax.WicketEndpoint.onOpen(WicketEndpoint.java:58)
[wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
        at
io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:84)
[undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
[undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:271)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:221)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1131)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1351)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.Connectors.terminateResponse(Connectors.java:78)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:273)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:207)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
        at
io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
        at
io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[rt.jar:1.7.0_65]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[rt.jar:1.7.0_65]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Sebastien <se...@gmail.com>.
Hi Martin,

Tested, I like it :)

Thanks,
Sebastien.


On Tue, Oct 28, 2014 at 10:37 AM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi Sebastien,
>
> I've improved it with https://issues.apache.org/jira/browse/WICKET-5737
> Please let me know if you see more improvements.
> Thanks !
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, Oct 23, 2014 at 8:08 PM, Sebastien <se...@gmail.com> wrote:
>
> > Hi Martin,
> >
> > I finally end up with the underlying issue, I will open a new thread for
> > that one... (I am not sure you will like it :s)
> >
> > Regarding this thread, I confirm you that's important to log the error
> > instead of throwing the UnsupportedOperationException. Actually, the
> error
> > message was empty but at least it did not "shortcut" the other
> exception. I
> > made the change locally that's what helps me to understand what was
> > happening...
> >
> > Thanks & best regards,
> > Sebastien.
> >
> >
> > On Mon, Oct 13, 2014 at 10:37 AM, Sebastien <se...@gmail.com> wrote:
> >
> > > Hi Martin,
> > >
> > > If #sendError() is called on purpose, then you are right it should not
> be
> > > ignored....
> > > Sadly, I do not have many time to investigate more on this and try to
> > > understand the exact behavior and the relationship with the error
> thrown
> > on
> > > my side. (It was part of a PoC I'm not supposed to work on for now...)
> > >
> > > I will let you know if I have some news...
> > >
> > > Thanks again & best regards,
> > > Sebastien.
> > >
> > >
> > >
> >
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Martin Grigorov <mg...@apache.org>.
Hi Sebastien,

I've improved it with https://issues.apache.org/jira/browse/WICKET-5737
Please let me know if you see more improvements.
Thanks !

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Oct 23, 2014 at 8:08 PM, Sebastien <se...@gmail.com> wrote:

> Hi Martin,
>
> I finally end up with the underlying issue, I will open a new thread for
> that one... (I am not sure you will like it :s)
>
> Regarding this thread, I confirm you that's important to log the error
> instead of throwing the UnsupportedOperationException. Actually, the error
> message was empty but at least it did not "shortcut" the other exception. I
> made the change locally that's what helps me to understand what was
> happening...
>
> Thanks & best regards,
> Sebastien.
>
>
> On Mon, Oct 13, 2014 at 10:37 AM, Sebastien <se...@gmail.com> wrote:
>
> > Hi Martin,
> >
> > If #sendError() is called on purpose, then you are right it should not be
> > ignored....
> > Sadly, I do not have many time to investigate more on this and try to
> > understand the exact behavior and the relationship with the error thrown
> on
> > my side. (It was part of a PoC I'm not supposed to work on for now...)
> >
> > I will let you know if I have some news...
> >
> > Thanks again & best regards,
> > Sebastien.
> >
> >
> >
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Sebastien <se...@gmail.com>.
Hi Martin,

I finally end up with the underlying issue, I will open a new thread for
that one... (I am not sure you will like it :s)

Regarding this thread, I confirm you that's important to log the error
instead of throwing the UnsupportedOperationException. Actually, the error
message was empty but at least it did not "shortcut" the other exception. I
made the change locally that's what helps me to understand what was
happening...

Thanks & best regards,
Sebastien.


On Mon, Oct 13, 2014 at 10:37 AM, Sebastien <se...@gmail.com> wrote:

> Hi Martin,
>
> If #sendError() is called on purpose, then you are right it should not be
> ignored....
> Sadly, I do not have many time to investigate more on this and try to
> understand the exact behavior and the relationship with the error thrown on
> my side. (It was part of a PoC I'm not supposed to work on for now...)
>
> I will let you know if I have some news...
>
> Thanks again & best regards,
> Sebastien.
>
>
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Sebastien <se...@gmail.com>.
Hi Martin,

If #sendError() is called on purpose, then you are right it should not be
ignored....
Sadly, I do not have many time to investigate more on this and try to
understand the exact behavior and the relationship with the error thrown on
my side. (It was part of a PoC I'm not supposed to work on for now...)

I will let you know if I have some news...

Thanks again & best regards,
Sebastien.


On Fri, Oct 10, 2014 at 5:59 PM, Martin Grigorov <mg...@apache.org>
wrote:

> On Fri, Oct 10, 2014 at 6:40 PM, Sebastien <se...@gmail.com> wrote:
>
> > Hi Martin,
> >
> > Thanks for your quick answer!
> >
> > Just to be sure we are on the same page, I do not call #sendError
> myself...
> > I suppose it is called automatically because an exception is thrown
> > elsewhere (let's considering this is the intended behavior in my
> case...).
> >
> > > One option is to replace "throw UnsupportedOperationException" with
> > log.warn.
> > I would personally just have replaced "throw new
> > UnsupportedOperationException()" by a "// noop" comment or something like
> > that. Logging a warning would mean the user can take an action to correct
> > this but - if I understood you correctly - that's not the case...
> >
>
> But do you really want the exception to be swallowed like this ?
> This will lead to a lot of confusion - an error happens and Wicket neither
> logs it nor sends any feedback back to the browser ...
>
>
> >
> > Checking that target IS-A WebSocketRequestHandler will be probably very
> > useful in a near future! :)
> >
> > Best regards,
> > Sebastien.
> >
> >
> > On Fri, Oct 10, 2014 at 5:21 PM, Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> > > Hi Sebastien,
> > >
> > > With https://issues.apache.org/jira/browse/WICKET-5701 I've added
> > support
> > > for RequestCycle.find(AjaxRequestTarget.class) and actually proper
> > support
> > > for scheduling any kind of IRequestHandler.
> > > In M3 your ErrorCodeRequestHandler has been just send to /dev/null.
> > >
> > > One option is to replace "throw UnsupportedOperationException" with
> > > log.warn.
> > > The idea is that your error code doesn't mean anything in the web
> socket
> > > response. It is not normal HTTP response so the browser won't try to
> > > process it ...
> > >
> > > In your code you can check whether this is a WebSocketRequestHandler
> and
> > > return something that your client side logic should process as an
> error.
> > > Or maybe WebSocketResponse.sendError() can write this for you: {"type":
> > > "error", "code": 456, "message": "optional"} ?
> > > But again it is up to your client side logic to process it.
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Fri, Oct 10, 2014 at 6:09 PM, Sebastien <se...@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > Using 7.0.0-SNAPSHOT, I've got a UnsupportedOperationException (see
> > > below)
> > > > whereas I do not have it on 7.0.0-M3. I don't really know how to
> > > > investigate as an UnsupportedOperationException seems to be the
> > expected
> > > > result [1], or maybe #sendError is not supposed to be called anyway,
> or
> > > it
> > > > is a regression from -M3...
> > > >
> > > > I'm using wicket-native-websocket-core &
> wicket-native-websocket-javax
> > on
> > > > WildFly8
> > > >
> > > > Thanks in advance for your advise,
> > > > Sebastien.
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketResponse.java#L193
> > > >
> > > > --
> > > > ERROR [org.apache.wicket.request.cycle.RequestCycle] Error during
> > > > processing error message: java.lang.UnsupportedOperationException
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.ws.api.WebSocketResponse.sendError(WebSocketResponse.java:193)
> > > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77)
> > > > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> > > > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:314)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:237)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
> > > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:219)
> > > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.onConnect(AbstractWebSocketProcessor.java:150)
> > > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.ws.javax.JavaxWebSocketProcessor.<init>(JavaxWebSocketProcessor.java:48)
> > > > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> org.apache.wicket.protocol.ws.javax.WicketEndpoint.onOpen(WicketEndpoint.java:58)
> > > > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:84)
> > > > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
> > > > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:271)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:221)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1131)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1351)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > > io.undertow.server.Connectors.terminateResponse(Connectors.java:78)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:273)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:207)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> > > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > > io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
> > > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > > >         at
> > > >
> > > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> > > > [rt.jar:1.7.0_65]
> > > >         at
> > > >
> > > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > > > [rt.jar:1.7.0_65]
> > > >         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
> > > >
> > >
> >
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Oct 10, 2014 at 6:40 PM, Sebastien <se...@gmail.com> wrote:

> Hi Martin,
>
> Thanks for your quick answer!
>
> Just to be sure we are on the same page, I do not call #sendError myself...
> I suppose it is called automatically because an exception is thrown
> elsewhere (let's considering this is the intended behavior in my case...).
>
> > One option is to replace "throw UnsupportedOperationException" with
> log.warn.
> I would personally just have replaced "throw new
> UnsupportedOperationException()" by a "// noop" comment or something like
> that. Logging a warning would mean the user can take an action to correct
> this but - if I understood you correctly - that's not the case...
>

But do you really want the exception to be swallowed like this ?
This will lead to a lot of confusion - an error happens and Wicket neither
logs it nor sends any feedback back to the browser ...


>
> Checking that target IS-A WebSocketRequestHandler will be probably very
> useful in a near future! :)
>
> Best regards,
> Sebastien.
>
>
> On Fri, Oct 10, 2014 at 5:21 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi Sebastien,
> >
> > With https://issues.apache.org/jira/browse/WICKET-5701 I've added
> support
> > for RequestCycle.find(AjaxRequestTarget.class) and actually proper
> support
> > for scheduling any kind of IRequestHandler.
> > In M3 your ErrorCodeRequestHandler has been just send to /dev/null.
> >
> > One option is to replace "throw UnsupportedOperationException" with
> > log.warn.
> > The idea is that your error code doesn't mean anything in the web socket
> > response. It is not normal HTTP response so the browser won't try to
> > process it ...
> >
> > In your code you can check whether this is a WebSocketRequestHandler and
> > return something that your client side logic should process as an error.
> > Or maybe WebSocketResponse.sendError() can write this for you: {"type":
> > "error", "code": 456, "message": "optional"} ?
> > But again it is up to your client side logic to process it.
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Fri, Oct 10, 2014 at 6:09 PM, Sebastien <se...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > Using 7.0.0-SNAPSHOT, I've got a UnsupportedOperationException (see
> > below)
> > > whereas I do not have it on 7.0.0-M3. I don't really know how to
> > > investigate as an UnsupportedOperationException seems to be the
> expected
> > > result [1], or maybe #sendError is not supposed to be called anyway, or
> > it
> > > is a regression from -M3...
> > >
> > > I'm using wicket-native-websocket-core & wicket-native-websocket-javax
> on
> > > WildFly8
> > >
> > > Thanks in advance for your advise,
> > > Sebastien.
> > >
> > > [1]
> > >
> > >
> >
> https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketResponse.java#L193
> > >
> > > --
> > > ERROR [org.apache.wicket.request.cycle.RequestCycle] Error during
> > > processing error message: java.lang.UnsupportedOperationException
> > >         at
> > >
> > >
> >
> org.apache.wicket.protocol.ws.api.WebSocketResponse.sendError(WebSocketResponse.java:193)
> > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77)
> > > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> > > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:314)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:237)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
> > > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:219)
> > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.onConnect(AbstractWebSocketProcessor.java:150)
> > > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.protocol.ws.javax.JavaxWebSocketProcessor.<init>(JavaxWebSocketProcessor.java:48)
> > > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> org.apache.wicket.protocol.ws.javax.WicketEndpoint.onOpen(WicketEndpoint.java:58)
> > > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> > >         at
> > >
> > >
> >
> io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:84)
> > > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
> > > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:271)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:221)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1131)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1351)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > > io.undertow.server.Connectors.terminateResponse(Connectors.java:78)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:273)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:207)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
> > >         at
> > >
> > >
> >
> io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
> > >         at
> > >
> > >
> >
> io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> > > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > > io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
> > > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> > >         at
> > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> > > [rt.jar:1.7.0_65]
> > >         at
> > >
> > >
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > > [rt.jar:1.7.0_65]
> > >         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
> > >
> >
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Sebastien <se...@gmail.com>.
Hi Martin,

Thanks for your quick answer!

Just to be sure we are on the same page, I do not call #sendError myself...
I suppose it is called automatically because an exception is thrown
elsewhere (let's considering this is the intended behavior in my case...).

> One option is to replace "throw UnsupportedOperationException" with
log.warn.
I would personally just have replaced "throw new
UnsupportedOperationException()" by a "// noop" comment or something like
that. Logging a warning would mean the user can take an action to correct
this but - if I understood you correctly - that's not the case...

Checking that target IS-A WebSocketRequestHandler will be probably very
useful in a near future! :)

Best regards,
Sebastien.


On Fri, Oct 10, 2014 at 5:21 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi Sebastien,
>
> With https://issues.apache.org/jira/browse/WICKET-5701 I've added support
> for RequestCycle.find(AjaxRequestTarget.class) and actually proper support
> for scheduling any kind of IRequestHandler.
> In M3 your ErrorCodeRequestHandler has been just send to /dev/null.
>
> One option is to replace "throw UnsupportedOperationException" with
> log.warn.
> The idea is that your error code doesn't mean anything in the web socket
> response. It is not normal HTTP response so the browser won't try to
> process it ...
>
> In your code you can check whether this is a WebSocketRequestHandler and
> return something that your client side logic should process as an error.
> Or maybe WebSocketResponse.sendError() can write this for you: {"type":
> "error", "code": 456, "message": "optional"} ?
> But again it is up to your client side logic to process it.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Oct 10, 2014 at 6:09 PM, Sebastien <se...@gmail.com> wrote:
>
> > Hi,
> >
> > Using 7.0.0-SNAPSHOT, I've got a UnsupportedOperationException (see
> below)
> > whereas I do not have it on 7.0.0-M3. I don't really know how to
> > investigate as an UnsupportedOperationException seems to be the expected
> > result [1], or maybe #sendError is not supposed to be called anyway, or
> it
> > is a regression from -M3...
> >
> > I'm using wicket-native-websocket-core & wicket-native-websocket-javax on
> > WildFly8
> >
> > Thanks in advance for your advise,
> > Sebastien.
> >
> > [1]
> >
> >
> https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketResponse.java#L193
> >
> > --
> > ERROR [org.apache.wicket.request.cycle.RequestCycle] Error during
> > processing error message: java.lang.UnsupportedOperationException
> >         at
> >
> >
> org.apache.wicket.protocol.ws.api.WebSocketResponse.sendError(WebSocketResponse.java:193)
> > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77)
> > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> > [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:314)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:237)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
> > [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:219)
> > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.onConnect(AbstractWebSocketProcessor.java:150)
> > [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.protocol.ws.javax.JavaxWebSocketProcessor.<init>(JavaxWebSocketProcessor.java:48)
> > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> org.apache.wicket.protocol.ws.javax.WicketEndpoint.onOpen(WicketEndpoint.java:58)
> > [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
> >         at
> >
> >
> io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:84)
> > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
> > [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:271)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:221)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1131)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1351)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> > io.undertow.server.Connectors.terminateResponse(Connectors.java:78)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:273)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:207)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
> >         at
> >
> >
> io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
> >         at
> >
> >
> io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> > [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> >         at
> > io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> > io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
> > [undertow-core-1.0.15.Final.jar:1.0.15.Final]
> >         at
> >
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> > [rt.jar:1.7.0_65]
> >         at
> >
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> > [rt.jar:1.7.0_65]
> >         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
> >
>

Re: [7.0.0-SNAPSHOT] WebSocketResponse#sendError throws UnsupportedOperationException

Posted by Martin Grigorov <mg...@apache.org>.
Hi Sebastien,

With https://issues.apache.org/jira/browse/WICKET-5701 I've added support
for RequestCycle.find(AjaxRequestTarget.class) and actually proper support
for scheduling any kind of IRequestHandler.
In M3 your ErrorCodeRequestHandler has been just send to /dev/null.

One option is to replace "throw UnsupportedOperationException" with
log.warn.
The idea is that your error code doesn't mean anything in the web socket
response. It is not normal HTTP response so the browser won't try to
process it ...

In your code you can check whether this is a WebSocketRequestHandler and
return something that your client side logic should process as an error.
Or maybe WebSocketResponse.sendError() can write this for you: {"type":
"error", "code": 456, "message": "optional"} ?
But again it is up to your client side logic to process it.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Oct 10, 2014 at 6:09 PM, Sebastien <se...@gmail.com> wrote:

> Hi,
>
> Using 7.0.0-SNAPSHOT, I've got a UnsupportedOperationException (see below)
> whereas I do not have it on 7.0.0-M3. I don't really know how to
> investigate as an UnsupportedOperationException seems to be the expected
> result [1], or maybe #sendError is not supposed to be called anyway, or it
> is a regression from -M3...
>
> I'm using wicket-native-websocket-core & wicket-native-websocket-javax on
> WildFly8
>
> Thanks in advance for your advise,
> Sebastien.
>
> [1]
>
> https://github.com/apache/wicket/blob/master/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketResponse.java#L193
>
> --
> ERROR [org.apache.wicket.request.cycle.RequestCycle] Error during
> processing error message: java.lang.UnsupportedOperationException
>         at
>
> org.apache.wicket.protocol.ws.api.WebSocketResponse.sendError(WebSocketResponse.java:193)
> [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77)
> [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:837)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> [wicket-request-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:314)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:323)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:237)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
> [wicket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:219)
> [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.onConnect(AbstractWebSocketProcessor.java:150)
> [wicket-native-websocket-core-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.protocol.ws.javax.JavaxWebSocketProcessor.<init>(JavaxWebSocketProcessor.java:48)
> [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> org.apache.wicket.protocol.ws.javax.WicketEndpoint.onOpen(WicketEndpoint.java:58)
> [wicket-native-websocket-javax-7.0.0-SNAPSHOT.jar:7.0.0-SNAPSHOT]
>         at
>
> io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:84)
> [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
> [undertow-websockets-jsr-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:271)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:221)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1131)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1351)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
> io.undertow.server.Connectors.terminateResponse(Connectors.java:78)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:273)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:207)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
>         at
>
> io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
>         at
>
> io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
>         at
> io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
> [undertow-core-1.0.15.Final.jar:1.0.15.Final]
>         at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [rt.jar:1.7.0_65]
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [rt.jar:1.7.0_65]
>         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
>