Author: remy.maucherat(a)jboss.com
Date: 2014-01-07 04:27:45 -0500 (Tue, 07 Jan 2014)
New Revision: 2335
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
Log:
Use my patch from Tomcat instead: don't do anything at all if nothing was written
yet.
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
===================================================================
---
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java 2014-01-06
18:06:29 UTC (rev 2334)
+++
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java 2014-01-07
09:27:45 UTC (rev 2335)
@@ -84,20 +84,23 @@
public void onWritePossible(boolean useDispatch) {
+ if (buffers == null) {
+ // Servlet 3.1 will call the write listener once even if nothing
+ // was written
+ return;
+ }
boolean complete = true;
try {
// If this is false there will be a call back when it is true
while (sos.isReady()) {
complete = true;
- if (buffers != null) {
- for (ByteBuffer buffer : buffers) {
- if (buffer.hasRemaining()) {
- complete = false;
- sos.write(buffer.array(), buffer.arrayOffset(),
- buffer.limit());
- buffer.position(buffer.limit());
- break;
- }
+ for (ByteBuffer buffer : buffers) {
+ if (buffer.hasRemaining()) {
+ complete = false;
+ sos.write(buffer.array(), buffer.arrayOffset(),
+ buffer.limit());
+ buffer.position(buffer.limit());
+ break;
}
}
if (complete) {
@@ -120,7 +123,6 @@
}
if (!complete) {
// Async write is in progress
-
long timeout = getSendTimeout();
if (timeout > 0) {
// Register with timeout thread