Bug 58414

Summary: Can not transfer empty string through Web Socket
Product: Tomcat 8 Reporter: Evgeny Mironenko <emironen0>
Component: WebSocketAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: critical CC: emironen0
Priority: P2    
Version: 8.0.26   
Target Milestone: ----   
Hardware: PC   
OS: All   
Attachments: Example of ServerEndpoint implementation.

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.