Author: markt
Date: Fri Dec 11 11:22:37 2015
New Revision: 1719348

URL: http://svn.apache.org/viewvc?rev=1719348&view=rev
Log:
Add some additional debug logging to WebSocket

Modified:
    
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
    
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
    
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsFrameServer.java

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1719348&r1=1719347&r2=1719348&view=diff
==============================================================================
--- 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
(original)
+++ 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties 
Fri Dec 11 11:22:37 2015
@@ -60,7 +60,8 @@ wsFrame.messageTooBig=The message was [{
 wsFrame.noContinuation=A new message was started when a continuation frame was 
expected
 wsFrame.notMasked=The client frame was not masked but all client frames must 
be masked
 wsFrame.oneByteCloseCode=The client sent a close frame with a single byte 
payload which is not valid
-wsFrame.sessionClosed=The client data can not be processed because the session 
has already been closed
+wsFrame.partialHeaderComplete=WebSocket frame received. fin [{0}], rsv [{1}], 
OpCode [{2}], payload length [{3}]
+wsFrame.sessionClosed=The client data cannot be processed because the session 
has already been closed
 wsFrame.textMessageTooBig=The decoded text message was too big for the output 
buffer and the endpoint does not support partial messages
 wsFrame.wrongRsv=The client frame set the reserved bits to [{0}] for a message 
with opCode [{1}] which was not supported by this endpoint
 

Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java?rev=1719348&r1=1719347&r2=1719348&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java 
(original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java Fri 
Dec 11 11:22:37 2015
@@ -30,6 +30,7 @@ import javax.websocket.Extension;
 import javax.websocket.MessageHandler;
 import javax.websocket.PongMessage;
 
+import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.Utf8Decoder;
 import org.apache.tomcat.util.res.StringManager;
@@ -220,11 +221,16 @@ public abstract class WsFrameBase {
         }
         payloadLength = b & 0x7F;
         state = State.PARTIAL_HEADER;
+        if (getLog().isDebugEnabled()) {
+            getLog().debug(sm.getString("wsFrame.partialHeaderComplete", 
Boolean.toString(fin),
+                    Integer.toString(rsv), Integer.toString(opCode), 
Long.toString(payloadLength)));
+        }
         return true;
     }
 
 
     protected abstract boolean isMasked();
+    protected abstract Log getLog();
 
 
     /**

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java?rev=1719348&r1=1719347&r2=1719348&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java 
(original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java 
Fri Dec 11 11:22:37 2015
@@ -105,6 +105,12 @@ public class WsFrameClient extends WsFra
     }
 
 
+    @Override
+    protected Log getLog() {
+        return log;
+    }
+
+
     private class WsFrameClientCompletionHandler
             implements CompletionHandler<Integer,Void> {
 

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties?rev=1719348&r1=1719347&r2=1719348&view=diff
==============================================================================
--- 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
 (original)
+++ 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
 Fri Dec 11 11:22:37 2015
@@ -31,6 +31,9 @@ uriTemplate.emptySegment=The path [{0}]
 uriTemplate.invalidPath=The path [{0}] is not valid.
 uriTemplate.invalidSegment=The segment [{0}] is not valid in the provided path 
[{1}]
 
+wsFrameServer.bytesRead=Read [{0}] bytes into input buffer ready for processing
+wsFrameServer.onDataAvailable=Method entry
+
 wsHttpUpgradeHandler.destroyFailed=Failed to close WebConnection while 
destroying the WebSocket HttpUpgradeHandler
 wsHttpUpgradeHandler.noPreInit=The preInit() method must be called to 
configure the WebSocket HttpUpgradeHandler before the container calls init(). 
Usually, this means the Servlet that created the WsHttpUpgradeHandler instance 
should also call preInit()
 

Modified: 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsFrameServer.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsFrameServer.java?rev=1719348&r1=1719347&r2=1719348&view=diff
==============================================================================
--- 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsFrameServer.java 
(original)
+++ 
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsFrameServer.java 
Fri Dec 11 11:22:37 2015
@@ -21,12 +21,18 @@ import java.io.IOException;
 
 import javax.servlet.ServletInputStream;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.Transformation;
 import org.apache.tomcat.websocket.WsFrameBase;
 import org.apache.tomcat.websocket.WsSession;
 
 public class WsFrameServer extends WsFrameBase {
 
+    private static final Log log = LogFactory.getLog(WsFrameServer.class);
+    private static final StringManager sm = 
StringManager.getManager(Constants.PACKAGE_NAME);
+
     private final ServletInputStream sis;
     private final Object connectionReadLock = new Object();
 
@@ -45,11 +51,16 @@ public class WsFrameServer extends WsFra
      *                     data
      */
     public void onDataAvailable() throws IOException {
+        if (log.isDebugEnabled()) {
+            log.debug("wsFrameServer.onDataAvailable");
+        }
         synchronized (connectionReadLock) {
             while (isOpen() && sis.isReady()) {
                 // Fill up the input buffer with as much data as we can
-                int read = sis.read(
-                        inputBuffer, writePos, inputBuffer.length - writePos);
+                int read = sis.read(inputBuffer, writePos, inputBuffer.length 
- writePos);
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("wsFrameServer.bytesRead", 
Integer.toString(read)));
+                }
                 if (read == 0) {
                     return;
                 }
@@ -75,4 +86,10 @@ public class WsFrameServer extends WsFra
         // Overridden to make it visible to other classes in this package
         return super.getTransformation();
     }
+
+
+    @Override
+    protected Log getLog() {
+        return log;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to