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

WebSocket Message InputStream read() returns signed byte #9006

Closed
jspechts opened this issue Dec 5, 2022 · 0 comments · Fixed by #9010
Closed

WebSocket Message InputStream read() returns signed byte #9006

jspechts opened this issue Dec 5, 2022 · 0 comments · Fixed by #9010
Labels
Bug For general bugs on Jetty side

Comments

@jspechts
Copy link

jspechts commented Dec 5, 2022

Jetty version(s)

10.0.12

Java version/vendor (use: java -version)

openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment Zulu11.45+28-SA (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.45+28-SA (build 11.0.10+9-LTS, mixed mode)

OS type/version

Tested on macOS 12.6.1 (though this is likely a OS-agnostic issue)

Description

In Jetty 9, reading any unsigned byte from 0 to 255 inclusive using the InputStream#read() API against the InputStream instance injected by Jetty into the method annotated with @OnWebSocketMessage for class annotated with @WebSocket worked well.

However, in Jetty 10, attempting to read an unsigned byte in the range 128 to 255 inclusive using the same setup fails since values in this range are returned as signed bytes (-128 to -1, inclusive), which breaks the InputStream#read() contract.

This is causing a problem for us when we use DataOutputStream / DataInputStream to write / read shorts (for example) using Jetty's WebSocket OutputStream / InputStream, since the signed byte returned by Jetty is interpreted as EOF.

How to reproduce?

See: https://github.com/jspechts/IGN-6520-JETTY-SSCCE

@jspechts jspechts added the Bug For general bugs on Jetty side label Dec 5, 2022
@joakime joakime closed this as completed in a546027 Dec 6, 2022
joakime added a commit that referenced this issue Dec 6, 2022
…eam-read

Fixes #9006 - WebSocket MessageInputStream.read() returns signed byte
@gregw gregw assigned gregw and unassigned gregw and lachlan-roberts Dec 6, 2022
@gregw gregw changed the title Jetty 9 -> 10 Upgrade Regression: WebSocket Message InputStream read() returns signed byte WebSocket Message InputStream read() returns signed byte Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants