Bug 58414 - Can not transfer empty string through Web Socket
Summary: Can not transfer empty string through Web Socket
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: 8.0.26
Hardware: PC All
: P2 critical (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-15 21:49 UTC by Evgeny Mironenko
Modified: 2015-09-19 07:42 UTC (History)
1 user (show)



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

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)
line:

    // 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.