Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted Exception in Tyrus thread #771

Closed
MaciejCiszewski opened this issue Feb 15, 2022 · 0 comments · Fixed by #773
Closed

Unwanted Exception in Tyrus thread #771

MaciejCiszewski opened this issue Feb 15, 2022 · 0 comments · Fixed by #773

Comments

@MaciejCiszewski
Copy link

MaciejCiszewski commented Feb 15, 2022

java.lang.IllegalArgumentException: Reason Phrase cannot exceed 123 UTF-8 encoded bytes: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@749a0411[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@1f9b7416[Wrapped task = org.glassfish.tyrus.core.TyrusSession$IdleTimeoutCommand@a6e78d8]] rejected from java.util.concurrent.ScheduledThreadPoolExecutor@3bb07421[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 132784]
at javax.websocket.CloseReason.(CloseReason.java:70)
at org.glassfish.tyrus.client.TyrusClientEngine$TyrusReadHandler.handle(TyrusClientEngine.java:734)
at org.glassfish.tyrus.container.jdk.client.ClientFilter.processRead(ClientFilter.java:204)
at org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)
at org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)
at org.glassfish.tyrus.container.jdk.client.SslFilter.handleRead(SslFilter.java:384)
at org.glassfish.tyrus.container.jdk.client.SslFilter.processRead(SslFilter.java:347)
at org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)
at org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)
at org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:294)
at org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:278)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:439)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:191)
at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:306)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

This is a stacktrace from version 1.18, but the latest master branch seems to have the same issue.

By the look of the code it seems that it appears against the intentions of the code. None of exceptions thrown in this place are expected to trigger such outcome as far as I see.

(https://github.com/eclipse-ee4j/tyrus/blob/master/client/src/main/java/org/glassfish/tyrus/client/TyrusClientEngine.java#L731-L735)

} 
catch (Exception e) {               
   LOGGER.log(Level.FINE, e.getMessage(), e);                
   socket.onClose(new CloseFrame(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, e.getMessage())));
}

https://github.com/javaee/websocket-spec/blob/master/api/client/src/main/java/javax/websocket/CloseReason.java#L69-L70

try {            
     if (reasonPhrase != null && reasonPhrase.getBytes("UTF-8").length > 123) {                
       throw new IllegalArgumentException("Reason Phrase cannot exceed 123 UTF-8 encoded bytes: " + reasonPhrase);            
     }

It looks that the exception handling code should either trim the string for e.getMessage() or create some generic message rather than try to use a string of unpredictable length in the face of such validation in websocket api.

@jansupol jansupol linked a pull request Feb 23, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant