Bug 57894 - IllegalStateException - BINARY_FULL_WRITING
Summary: IllegalStateException - BINARY_FULL_WRITING
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: 8.0.21
Hardware: All All
: P2 critical (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-05 16:29 UTC by Weizhi Yao
Modified: 2015-05-05 19:30 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Weizhi Yao 2015-05-05 16:29:49 UTC
WsRemoteEndpointImplBase.sendBinary is not synchronized. And there's no way to detect the state outside.

client -> server -> client -> server

The second time client call sendBinary may fail due to the race condition of stateMachine.binaryStart and stateMachine.complete

java.lang.IllegalStateException: The remote endpoint was in state [BINARY_FULL_WRITING] which is an invalid state for called method
	at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1148)
	at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.binaryStart(WsRemoteEndpointImplBase.java:1101)
	at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendBytes(WsRemoteEndpointImplBase.java:131)
	at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendBinary(WsRemoteEndpointBasic.java:43)
Comment 1 Mark Thomas 2015-05-05 19:12:53 UTC
The client knows that it called sendBinary() and that that call has not returned. The client therefore *does* know that it should not make another call to sendBinary(). Keeping track of all of this is a client responsibility. (If you want to change that, lobby the WebSocket EG).

Note the Javadoc for RemoteEndpoint.Basic:
file:///D:/specs/tc8/ws/ws-jsr-356-1.1-final-javadoc/javax/websocket/RemoteEndpoint.Basic.html
Comment 2 Chuck Caldarale 2015-05-05 19:28:51 UTC
(In reply to Mark Thomas from comment #1)
> Note the Javadoc for RemoteEndpoint.Basic:
> file:///D:/specs/tc8/ws/ws-jsr-356-1.1-final-javadoc/javax/websocket/
> RemoteEndpoint.Basic.html

This link might work a little better:
http://download.oracle.com/otndocs/jcp/websocket-1_1-mrel-spec/index.html
Comment 3 Chuck Caldarale 2015-05-05 19:30:51 UTC
(In reply to Chuck Caldarale from comment #2)
> (In reply to Mark Thomas from comment #1)
> > Note the Javadoc for RemoteEndpoint.Basic:
> > file:///D:/specs/tc8/ws/ws-jsr-356-1.1-final-javadoc/javax/websocket/
> > RemoteEndpoint.Basic.html
> 
> This link might work a little better:
> http://download.oracle.com/otndocs/jcp/websocket-1_1-mrel-spec/index.html

The above is for the entire JSR 356; for the online specific reference:
http://docs.oracle.com/javaee/7/api/javax/websocket/RemoteEndpoint.Basic.html