Author: markt
Date: Thu Jan 24 09:37:17 2013
New Revision: 1437919
URL: http://svn.apache.org/viewvc?rev=1437919&view=rev
Log:
Address some TODOs
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointClient.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1437919&r1=1437918&r2=1437919&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Thu
Jan 24 09:37:17 2013
@@ -20,6 +20,7 @@ messageSendStateMachine.inProgress=Messa
# frames and therefore must be 123 bytes (not characters) or less in length.
# Messages are encoded using UTF-8 where a single character may be encoded in
# as many as 4 bytes.
+wsFrame.bufferToSmall=No async message support and buffer too small. Buffer
size: [{0}], Message size: [{1}]
wsFrame.byteToLongFail=Too many bytes ([{0}]) were provided to be converted
into a long
wsFrame.controlFragmented=A fragmented control frame was received but control
frames may not be fragmented
wsFrame.controlPayloadTooBig=A control frame was sent with a payload of size
[{0}] which is larger than the maximum permitted of 125 bytes
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java?rev=1437919&r1=1437918&r2=1437919&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java Thu Jan 24
09:37:17 2013
@@ -41,7 +41,7 @@ public abstract class WsFrameBase {
StringManager.getManager(Constants.PACKAGE_NAME);
// Connection level attributes
- private final WsSession wsSession;
+ protected final WsSession wsSession;
protected final byte[] inputBuffer;
// Attributes for control messages
@@ -493,10 +493,10 @@ public abstract class WsFrameBase {
return;
}
if (!usePartial() && (inputBuffer.length < payloadLength)) {
- // TODO i18n - buffer too small
CloseReason cr = new CloseReason(CloseCodes.TOO_BIG,
- "Buffer size: [" + inputBuffer.length +
- "], payload size: [" + payloadLength + "]");
+ sm.getString("wsFrame.bufferToSmall",
+ Integer.valueOf(inputBuffer.length),
+ Long.valueOf(payloadLength)));
wsSession.close(cr);
wsSession.onClose(cr);
throw new IOException(cr.getReasonPhrase());
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java?rev=1437919&r1=1437918&r2=1437919&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java Thu Jan 24
09:37:17 2013
@@ -21,6 +21,9 @@ import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
+import javax.websocket.CloseReason;
+import javax.websocket.CloseReason.CloseCodes;
+
public class WsFrameClient extends WsFrameBase {
private ByteBuffer response;
@@ -34,11 +37,11 @@ public class WsFrameClient extends WsFra
this.channel = channel;
this.handler = new WsFrameClientCompletionHandler();
- tbd();
+ processSocketRead();
}
- private void tbd() throws IOException {
+ private void processSocketRead() throws IOException {
while (response.hasRemaining()) {
int remaining = response.remaining();
@@ -74,16 +77,25 @@ public class WsFrameClient extends WsFra
public void completed(Integer result, Void attachment) {
response.flip();
try {
- tbd();
+ processSocketRead();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ close(e);
}
}
@Override
public void failed(Throwable exc, Void attachment) {
- // TODO Auto-generated method stub
+ close(exc);
+ }
+
+ private final void close(Throwable t) {
+ CloseReason cr = new CloseReason(
+ CloseCodes.CLOSED_ABNORMALLY, t.getMessage());
+ try {
+ wsSession.close(cr);
+ } catch (IOException ignore) {
+ // Ignore
+ }
}
}
}
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointClient.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointClient.java?rev=1437919&r1=1437918&r2=1437919&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointClient.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointClient.java
Thu Jan 24 09:37:17 2013
@@ -46,9 +46,8 @@ public class WsRemoteEndpointClient exte
protected void close() {
try {
channel.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (IOException ignore) {
+ // Ignore
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]