Author: markt Date: Wed Feb 6 11:17:41 2019 New Revision: 1853062 URL: http://svn.apache.org/viewvc?rev=1853062&view=rev Log: Implement an alternative solution to four failing TCK test and (yah!) remove a system property.
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java tomcat/trunk/webapps/docs/changelog.xml tomcat/trunk/webapps/docs/config/systemprops.xml Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java?rev=1853062&r1=1853061&r2=1853062&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java Wed Feb 6 11:17:41 2019 @@ -133,10 +133,6 @@ public class Constants { static final boolean ALLOW_UNSUPPORTED_EXTENSIONS = Boolean.getBoolean("org.apache.tomcat.websocket.ALLOW_UNSUPPORTED_EXTENSIONS"); - // Configuration for stream behavior - static final boolean STREAMS_DROP_EMPTY_MESSAGES = - Boolean.getBoolean("org.apache.tomcat.websocket.STREAMS_DROP_EMPTY_MESSAGES"); - public static final boolean STRICT_SPEC_COMPLIANCE = Boolean.getBoolean("org.apache.tomcat.websocket.STRICT_SPEC_COMPLIANCE"); Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1853062&r1=1853061&r2=1853062&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java Wed Feb 6 11:17:41 2019 @@ -983,15 +983,17 @@ public abstract class WsRemoteEndpointIm throw new IllegalStateException( sm.getString("wsRemoteEndpoint.closedOutputStream")); } - if (len == 0) { - return; - } if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } used = true; + + if (len == 0) { + return; + } + if (buffer.remaining() == 0) { flush(); } @@ -1016,7 +1018,7 @@ public abstract class WsRemoteEndpointIm // Optimisation. If there is no data to flush then do not send an // empty message. - if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || buffer.position() > 0) { + if (buffer.position() > 0) { doWrite(false); } } @@ -1034,7 +1036,7 @@ public abstract class WsRemoteEndpointIm } private void doWrite(boolean last) throws IOException { - if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || used) { + if (used) { buffer.flip(); endpoint.sendMessageBlock(Constants.OPCODE_BINARY, buffer, last); } @@ -1062,15 +1064,17 @@ public abstract class WsRemoteEndpointIm throw new IllegalStateException( sm.getString("wsRemoteEndpoint.closedWriter")); } - if (len == 0) { - return; - } if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } used = true; + + if (len == 0) { + return; + } + if (buffer.remaining() == 0) { flush(); } @@ -1093,7 +1097,7 @@ public abstract class WsRemoteEndpointIm sm.getString("wsRemoteEndpoint.closedWriter")); } - if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || buffer.position() > 0) { + if (buffer.position() > 0) { doWrite(false); } } @@ -1111,7 +1115,7 @@ public abstract class WsRemoteEndpointIm } private void doWrite(boolean last) throws IOException { - if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || used) { + if (used) { buffer.flip(); endpoint.sendMessageBlock(buffer, last); buffer.clear(); Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1853062&r1=1853061&r2=1853062&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Feb 6 11:17:41 2019 @@ -45,6 +45,21 @@ issues do not "pop up" wrt. others). --> <section name="Tomcat 9.0.17 (markt)" rtext="in development"> + <subsection name="WebSocket"> + <changelog> + <scode> + Remove the <code>STREAMS_DROP_EMPTY_MESSAGES</code> system property that + was introduced to work-around four failing TCK tests. An alternative + solution has been implemented. Sending messages via + <code>getSendStream()</code> and <code>getSendWriter()</code> will now + only result in messages on the wire if data is written to the + <code>OutputStream</code> or <code>Writer</code>. Writing zero length + data will result in an empty message. Note that sending a message via an + <code>Encoder</code> may result in the message being send via + <code>getSendStream()</code> or <code>getSendWriter()</code>. (markt) + </scode> + </changelog> + </subsection> <subsection name="Tribes"> <changelog> <add> Modified: tomcat/trunk/webapps/docs/config/systemprops.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1853062&r1=1853061&r2=1853062&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/systemprops.xml (original) +++ tomcat/trunk/webapps/docs/config/systemprops.xml Wed Feb 6 11:17:41 2019 @@ -553,14 +553,6 @@ <p>The default value is <code>false</code>.</p> </property> - <property name="org.apache.tomcat. websocket.STREAMS_DROP_EMPTY_MESSAGES"> - <p>If <code>true</code>, streams provided to the user (writer and output - stream) will not send an empty message when flushing and there is no - data to flush, or when it is closed without having been used (for - example if an error occurs).</p> - <p>The default value is <code>false</code>.</p> - </property> - </properties> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org