From d23766fa27c6a7c204aab288d962b087bb17e322 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 12 Nov 2012 09:43:14 +0900 Subject: [PATCH] Replace a variable with a constant wherever possible --- .../http/multipart/HttpPostRequestDecoder.java | 8 ++++---- .../WebSocketClientHandshakerFactory.java | 14 ++++++++------ .../jboss/netty/util/internal/jzlib/InfBlocks.java | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java index c02e3fa1c5..6e9e053524 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java @@ -1339,11 +1339,11 @@ public class HttpPostRequestDecoder { } else if (nextByte == HttpConstants.LF) { return sb.toString(); } else if (nextByte == '-') { - sb.append((char) nextByte); + sb.append('-'); // second check for closing delimiter nextByte = undecodedChunk.readByte(); if (nextByte == '-') { - sb.append((char) nextByte); + sb.append('-'); // now try to find if CRLF or LF there if (undecodedChunk.readable()) { nextByte = undecodedChunk.readByte(); @@ -1439,12 +1439,12 @@ public class HttpPostRequestDecoder { sao.setReadPosition(0); return sb.toString(); } else if (nextByte == '-') { - sb.append((char) nextByte); + sb.append('-'); // second check for closing delimiter if (sao.pos < sao.limit) { nextByte = sao.bytes[sao.pos ++]; if (nextByte == '-') { - sb.append((char) nextByte); + sb.append('-'); // now try to find if CRLF or LF there if (sao.pos < sao.limit) { nextByte = sao.bytes[sao.pos++]; diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java index 4c30b25466..ff07a53236 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java @@ -18,6 +18,8 @@ package org.jboss.netty.handler.codec.http.websocketx; import java.net.URI; import java.util.Map; +import static org.jboss.netty.handler.codec.http.websocketx.WebSocketVersion.*; + /** * Instances the appropriate handshake class to use for clients */ @@ -66,17 +68,17 @@ public class WebSocketClientHandshakerFactory { public WebSocketClientHandshaker newHandshaker( URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map customHeaders, long maxFramePayloadLength) { - if (version == WebSocketVersion.V13) { + if (version == V13) { return new WebSocketClientHandshaker13( - webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength); + webSocketURL, V13, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength); } - if (version == WebSocketVersion.V08) { + if (version == V08) { return new WebSocketClientHandshaker08( - webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength); + webSocketURL, V08, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength); } - if (version == WebSocketVersion.V00) { + if (version == V00) { return new WebSocketClientHandshaker00( - webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength); + webSocketURL, V00, subprotocol, customHeaders, maxFramePayloadLength); } throw new WebSocketHandshakeException("Protocol version " + version.toString() + " not supported."); diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/InfBlocks.java b/src/main/java/org/jboss/netty/util/internal/jzlib/InfBlocks.java index 4b62c092db..c926984cb4 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/InfBlocks.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/InfBlocks.java @@ -259,7 +259,7 @@ final class InfBlocks { if (n == 0) { bitb = b; bitk = k; - z.avail_in = n; + z.avail_in = 0; z.total_in += p - z.next_in_index; z.next_in_index = p; write = q;