You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/03/26 17:45:15 UTC

svn commit: r1669370 - /tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java

Author: markt
Date: Thu Mar 26 16:45:15 2015
New Revision: 1669370

URL: http://svn.apache.org/r1669370
Log:
Use constants for constant byte arrays.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1669370&r1=1669369&r2=1669370&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Thu Mar 26 16:45:15 2015
@@ -70,11 +70,15 @@ import org.apache.tomcat.websocket.pojo.
 
 public class WsWebSocketContainer implements WebSocketContainer, BackgroundProcess {
 
-    private static final StringManager sm =
-            StringManager.getManager(WsWebSocketContainer.class);
+    private static final StringManager sm = StringManager.getManager(WsWebSocketContainer.class);
     private static final Random random = new Random();
     private static final byte[] crlf = new byte[] {13, 10};
 
+    private static final byte[] GET_BYTES = "GET ".getBytes(StandardCharsets.ISO_8859_1);
+    private static final byte[] ROOT_URI_BYTES = "/".getBytes(StandardCharsets.ISO_8859_1);
+    private static final byte[] HTTP_VERSION_BYTES =
+            " HTTP/1.1\r\n".getBytes(StandardCharsets.ISO_8859_1);
+
     private volatile AsynchronousChannelGroup asynchronousChannelGroup = null;
     private final Object asynchronousChannelGroupLock = new Object();
 
@@ -500,17 +504,16 @@ public class WsWebSocketContainer implem
         ByteBuffer result = ByteBuffer.allocate(4 * 1024);
 
         // Request line
-        result.put("GET ".getBytes(StandardCharsets.ISO_8859_1));
+        result.put(GET_BYTES);
         byte[] path = (null == uri.getPath() || "".equals(uri.getPath()))
-                ? "/".getBytes(StandardCharsets.ISO_8859_1)
-                : uri.getRawPath().getBytes(StandardCharsets.ISO_8859_1);
+                ? ROOT_URI_BYTES : uri.getRawPath().getBytes(StandardCharsets.ISO_8859_1);
         result.put(path);
         String query = uri.getRawQuery();
         if (query != null) {
             result.put((byte) '?');
             result.put(query.getBytes(StandardCharsets.ISO_8859_1));
         }
-        result.put(" HTTP/1.1\r\n".getBytes(StandardCharsets.ISO_8859_1));
+        result.put(HTTP_VERSION_BYTES);
 
         // Headers
         Iterator<Entry<String,List<String>>> iter =



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