Bug 58414 - Can not transfer empty string through Web Socket
Can not transfer empty string through Web Socket
Product: Tomcat 8
Classification: Unclassified
Component: WebSocket
PC All
: P2 critical (vote)
: ----
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2015-09-15 21:49 UTC by Evgeny Mironenko
Modified: 2015-09-19 07:42 UTC (History)
1 user (show)

Example of ServerEndpoint implementation. (2.09 KB, text/plain)
2015-09-15 21:49 UTC, Evgeny Mironenko

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeny Mironenko 2015-09-15 21:49:38 UTC
Created attachment 33111 [details]
Example of ServerEndpoint implementation.

Every time, when I try to transfer empty string through web socket I get an IllegalArgumentException from java.nio.Buffer#limit(int newLimit) because of negative new limit value. The reason of this issue is org.apache.tomcat.websocket.PerMessageDeflate#sendMessagePart(List<MessagePart> uncompressedParts)

    // End of compressed message. Drop EOM bytes and output.
    compressedPayload.limit(compressedPayload.limit() - EOM_BYTES.length);

compressedPayload.limit() has zero value and EOM_BYES.length has value, which greater than 0.
Comment 1 Mark Thomas 2015-09-18 16:33:00 UTC
I've been able to reproduce this with some edits to the chat example that ships with Tomcat. Working on a fix now.
Comment 2 Mark Thomas 2015-09-19 07:42:35 UTC
Fixed in trunk, 8.0.x (for 8.0.27 onwards) and 7.0.x for 7.0.65 onwards.