Remove redundant 'else' branches.
This commit is contained in:
parent
4cd7fb1abb
commit
12115198d0
|
@ -280,7 +280,8 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
|||
} else {
|
||||
return readBytes;
|
||||
}
|
||||
} else if (localReadBytes == 0) {
|
||||
}
|
||||
if (localReadBytes == 0) {
|
||||
break;
|
||||
}
|
||||
readBytes += localReadBytes;
|
||||
|
|
|
@ -1014,7 +1014,8 @@ public final class ChannelBuffers {
|
|||
long vb = bufferB.getUnsignedInt(bIndex);
|
||||
if (va > vb) {
|
||||
return 1;
|
||||
} else if (va < vb) {
|
||||
}
|
||||
if (va < vb) {
|
||||
return -1;
|
||||
}
|
||||
aIndex += 4;
|
||||
|
@ -1026,7 +1027,8 @@ public final class ChannelBuffers {
|
|||
long vb = swapInt(bufferB.getInt(bIndex)) & 0xFFFFFFFFL;
|
||||
if (va > vb) {
|
||||
return 1;
|
||||
} else if (va < vb) {
|
||||
}
|
||||
if (va < vb) {
|
||||
return -1;
|
||||
}
|
||||
aIndex += 4;
|
||||
|
@ -1039,7 +1041,8 @@ public final class ChannelBuffers {
|
|||
short vb = bufferB.getUnsignedByte(bIndex);
|
||||
if (va > vb) {
|
||||
return 1;
|
||||
} else if (va < vb) {
|
||||
}
|
||||
if (va < vb) {
|
||||
return -1;
|
||||
}
|
||||
aIndex ++;
|
||||
|
|
|
@ -172,7 +172,8 @@ public abstract class HeapChannelBuffer extends AbstractChannelBuffer {
|
|||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (localReadBytes == 0) {
|
||||
}
|
||||
if (localReadBytes == 0) {
|
||||
break;
|
||||
}
|
||||
readBytes += localReadBytes;
|
||||
|
|
|
@ -298,9 +298,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||
|
||||
try {
|
||||
synchronized (this) {
|
||||
if (done) {
|
||||
return done;
|
||||
} else if (waitTime <= 0) {
|
||||
if (done || waitTime <= 0) {
|
||||
return done;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,12 @@
|
|||
*/
|
||||
package org.jboss.netty.channel.group;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.*;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -26,12 +31,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
import static java.util.concurrent.TimeUnit.*;
|
||||
|
||||
/**
|
||||
* The default {@link ChannelGroupFuture} implementation.
|
||||
|
@ -275,9 +275,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||
|
||||
try {
|
||||
synchronized (this) {
|
||||
if (done) {
|
||||
return done;
|
||||
} else if (waitTime <= 0) {
|
||||
if (done || waitTime <= 0) {
|
||||
return done;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,14 @@
|
|||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
import org.jboss.netty.channel.socket.InternetProtocolFamily;
|
||||
import org.jboss.netty.util.internal.DetectionUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
|
@ -31,14 +38,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
import org.jboss.netty.channel.socket.InternetProtocolFamily;
|
||||
import org.jboss.netty.util.internal.DetectionUtil;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
/**
|
||||
* Provides an NIO based {@link org.jboss.netty.channel.socket.DatagramChannel}.
|
||||
|
@ -148,38 +148,38 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
|
|||
InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) {
|
||||
if (DetectionUtil.javaVersion() < 7) {
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
if (multicastAddress == null) {
|
||||
throw new NullPointerException("multicastAddress");
|
||||
}
|
||||
|
||||
if (multicastAddress == null) {
|
||||
throw new NullPointerException("multicastAddress");
|
||||
}
|
||||
|
||||
if (networkInterface == null) {
|
||||
throw new NullPointerException("networkInterface");
|
||||
}
|
||||
|
||||
try {
|
||||
MembershipKey key;
|
||||
if (source == null) {
|
||||
key = channel.join(multicastAddress, networkInterface);
|
||||
} else {
|
||||
key = channel.join(multicastAddress, networkInterface, source);
|
||||
}
|
||||
|
||||
if (networkInterface == null) {
|
||||
throw new NullPointerException("networkInterface");
|
||||
}
|
||||
synchronized (this) {
|
||||
if (memberships == null) {
|
||||
memberships = new HashMap<InetAddress, List<MembershipKey>>();
|
||||
|
||||
try {
|
||||
MembershipKey key;
|
||||
if (source == null) {
|
||||
key = channel.join(multicastAddress, networkInterface);
|
||||
} else {
|
||||
key = channel.join(multicastAddress, networkInterface, source);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (memberships == null) {
|
||||
memberships = new HashMap<InetAddress, List<MembershipKey>>();
|
||||
|
||||
}
|
||||
List<MembershipKey> keys = memberships.get(multicastAddress);
|
||||
if (keys == null) {
|
||||
keys = new ArrayList<MembershipKey>();
|
||||
memberships.put(multicastAddress, keys);
|
||||
}
|
||||
keys.add(key);
|
||||
List<MembershipKey> keys = memberships.get(multicastAddress);
|
||||
if (keys == null) {
|
||||
keys = new ArrayList<MembershipKey>();
|
||||
memberships.put(multicastAddress, keys);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return failedFuture(this, e);
|
||||
keys.add(key);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return failedFuture(this, e);
|
||||
}
|
||||
return succeededFuture(this);
|
||||
}
|
||||
|
|
|
@ -40,9 +40,11 @@ final class SocketReceiveBufferAllocator implements ExternalResourceReleasable {
|
|||
ByteBuffer get(int size) {
|
||||
if (buf == null) {
|
||||
return newBuffer(size);
|
||||
} else if (buf.capacity() < size) {
|
||||
}
|
||||
if (buf.capacity() < size) {
|
||||
return newBuffer(size);
|
||||
} else if (buf.capacity() * percentual / 100 > size) {
|
||||
}
|
||||
if (buf.capacity() * percentual / 100 > size) {
|
||||
if (++exceedCount == maxExceedCount) {
|
||||
return newBuffer(size);
|
||||
} else {
|
||||
|
|
|
@ -44,7 +44,8 @@ final class SocketSendBufferPool implements ExternalResourceReleasable {
|
|||
SendBuffer acquire(Object message) {
|
||||
if (message instanceof ChannelBuffer) {
|
||||
return acquire((ChannelBuffer) message);
|
||||
} else if (message instanceof FileRegion) {
|
||||
}
|
||||
if (message instanceof FileRegion) {
|
||||
return acquire((FileRegion) message);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||
res.setContent(content);
|
||||
sendHttpResponse(ctx, req, res);
|
||||
return;
|
||||
} else if ("/favicon.ico".equals(req.getUri())) {
|
||||
}
|
||||
if ("/favicon.ico".equals(req.getUri())) {
|
||||
HttpResponse res = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
|
||||
sendHttpResponse(ctx, req, res);
|
||||
return;
|
||||
|
@ -105,10 +106,12 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||
if (frame instanceof CloseWebSocketFrame) {
|
||||
handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
return;
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
}
|
||||
if (frame instanceof PingWebSocketFrame) {
|
||||
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
|
||||
return;
|
||||
} else if (!(frame instanceof TextWebSocketFrame)) {
|
||||
}
|
||||
if (!(frame instanceof TextWebSocketFrame)) {
|
||||
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
|
||||
.getName()));
|
||||
}
|
||||
|
|
|
@ -15,12 +15,6 @@
|
|||
*/
|
||||
package org.jboss.netty.example.http.websocketx.sslserver;
|
||||
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpMethod.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpVersion.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
|
@ -44,6 +38,12 @@ import org.jboss.netty.logging.InternalLogger;
|
|||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpMethod.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpVersion.*;
|
||||
|
||||
/**
|
||||
* Handles handshakes and messages
|
||||
*/
|
||||
|
@ -83,7 +83,9 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
|||
res.setContent(content);
|
||||
sendHttpResponse(ctx, req, res);
|
||||
return;
|
||||
} else if ("/favicon.ico".equals(req.getUri())) {
|
||||
}
|
||||
|
||||
if ("/favicon.ico".equals(req.getUri())) {
|
||||
HttpResponse res = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
|
||||
sendHttpResponse(ctx, req, res);
|
||||
return;
|
||||
|
@ -106,10 +108,12 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
|||
if (frame instanceof CloseWebSocketFrame) {
|
||||
handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
return;
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
}
|
||||
if (frame instanceof PingWebSocketFrame) {
|
||||
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
|
||||
return;
|
||||
} else if (!(frame instanceof TextWebSocketFrame)) {
|
||||
}
|
||||
if (!(frame instanceof TextWebSocketFrame)) {
|
||||
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
|
||||
.getName()));
|
||||
}
|
||||
|
|
|
@ -430,7 +430,8 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
|||
// Probably it is reading on.
|
||||
continue;
|
||||
}
|
||||
} else if (oldReaderIndex == cumulation.readerIndex()) {
|
||||
}
|
||||
if (oldReaderIndex == cumulation.readerIndex()) {
|
||||
throw new IllegalStateException(
|
||||
"decode() method must read at least one byte " +
|
||||
"if it returned a frame (caused by: " + getClass() + ')');
|
||||
|
|
|
@ -30,7 +30,8 @@ public class HttpContentDecompressor extends HttpContentDecoder {
|
|||
protected DecoderEmbedder<ChannelBuffer> newContentDecoder(String contentEncoding) throws Exception {
|
||||
if ("gzip".equalsIgnoreCase(contentEncoding) || "x-gzip".equalsIgnoreCase(contentEncoding)) {
|
||||
return new DecoderEmbedder<ChannelBuffer>(new ZlibDecoder(ZlibWrapper.GZIP));
|
||||
} else if ("deflate".equalsIgnoreCase(contentEncoding) || "x-deflate".equalsIgnoreCase(contentEncoding)) {
|
||||
}
|
||||
if ("deflate".equalsIgnoreCase(contentEncoding) || "x-deflate".equalsIgnoreCase(contentEncoding)) {
|
||||
// To be strict, 'deflate' means ZLIB, but some servers were not implemented correctly.
|
||||
return new DecoderEmbedder<ChannelBuffer>(new ZlibDecoder(ZlibWrapper.ZLIB_OR_NONE));
|
||||
}
|
||||
|
|
|
@ -197,42 +197,42 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
|||
message.setChunked(true);
|
||||
// Generate HttpMessage first. HttpChunks will follow.
|
||||
return message;
|
||||
} else if (nextState == State.SKIP_CONTROL_CHARS) {
|
||||
}
|
||||
if (nextState == State.SKIP_CONTROL_CHARS) {
|
||||
// No content is expected.
|
||||
// Remove the headers which are not supposed to be present not
|
||||
// to confuse subsequent handlers.
|
||||
message.removeHeader(HttpHeaders.Names.TRANSFER_ENCODING);
|
||||
return message;
|
||||
} else {
|
||||
long contentLength = HttpHeaders.getContentLength(message, -1);
|
||||
if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) {
|
||||
content = ChannelBuffers.EMPTY_BUFFER;
|
||||
return reset();
|
||||
}
|
||||
}
|
||||
long contentLength = HttpHeaders.getContentLength(message, -1);
|
||||
if (contentLength == 0 || contentLength == -1 && isDecodingRequest()) {
|
||||
content = ChannelBuffers.EMPTY_BUFFER;
|
||||
return reset();
|
||||
}
|
||||
|
||||
switch (nextState) {
|
||||
case READ_FIXED_LENGTH_CONTENT:
|
||||
if (contentLength > maxChunkSize || HttpHeaders.is100ContinueExpected(message)) {
|
||||
// Generate HttpMessage first. HttpChunks will follow.
|
||||
checkpoint(State.READ_FIXED_LENGTH_CONTENT_AS_CHUNKS);
|
||||
message.setChunked(true);
|
||||
// chunkSize will be decreased as the READ_FIXED_LENGTH_CONTENT_AS_CHUNKS
|
||||
// state reads data chunk by chunk.
|
||||
chunkSize = HttpHeaders.getContentLength(message, -1);
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
case READ_VARIABLE_LENGTH_CONTENT:
|
||||
if (buffer.readableBytes() > maxChunkSize || HttpHeaders.is100ContinueExpected(message)) {
|
||||
// Generate HttpMessage first. HttpChunks will follow.
|
||||
checkpoint(State.READ_VARIABLE_LENGTH_CONTENT_AS_CHUNKS);
|
||||
message.setChunked(true);
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected state: " + nextState);
|
||||
switch (nextState) {
|
||||
case READ_FIXED_LENGTH_CONTENT:
|
||||
if (contentLength > maxChunkSize || HttpHeaders.is100ContinueExpected(message)) {
|
||||
// Generate HttpMessage first. HttpChunks will follow.
|
||||
checkpoint(State.READ_FIXED_LENGTH_CONTENT_AS_CHUNKS);
|
||||
message.setChunked(true);
|
||||
// chunkSize will be decreased as the READ_FIXED_LENGTH_CONTENT_AS_CHUNKS
|
||||
// state reads data chunk by chunk.
|
||||
chunkSize = HttpHeaders.getContentLength(message, -1);
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
case READ_VARIABLE_LENGTH_CONTENT:
|
||||
if (buffer.readableBytes() > maxChunkSize || HttpHeaders.is100ContinueExpected(message)) {
|
||||
// Generate HttpMessage first. HttpChunks will follow.
|
||||
checkpoint(State.READ_VARIABLE_LENGTH_CONTENT_AS_CHUNKS);
|
||||
message.setChunked(true);
|
||||
return message;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected state: " + nextState);
|
||||
}
|
||||
// We return null here, this forces decode to be called again where we will decode the content
|
||||
return null;
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
/**
|
||||
* Default factory giving Attribute and FileUpload according to constructor
|
||||
*
|
||||
|
@ -98,7 +98,8 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
|||
List<HttpData> fileToDelete = getList(request);
|
||||
fileToDelete.add(attribute);
|
||||
return attribute;
|
||||
} else if (checkSize) {
|
||||
}
|
||||
if (checkSize) {
|
||||
Attribute attribute = new MixedAttribute(name, minSize);
|
||||
List<HttpData> fileToDelete = getList(request);
|
||||
fileToDelete.add(attribute);
|
||||
|
@ -119,7 +120,8 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
|||
List<HttpData> fileToDelete = getList(request);
|
||||
fileToDelete.add(attribute);
|
||||
return attribute;
|
||||
} else if (checkSize) {
|
||||
}
|
||||
if (checkSize) {
|
||||
Attribute attribute = new MixedAttribute(name, value, minSize);
|
||||
List<HttpData> fileToDelete = getList(request);
|
||||
fileToDelete.add(attribute);
|
||||
|
@ -141,7 +143,8 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
|||
List<HttpData> fileToDelete = getList(request);
|
||||
fileToDelete.add(fileUpload);
|
||||
return fileUpload;
|
||||
} else if (checkSize) {
|
||||
}
|
||||
if (checkSize) {
|
||||
FileUpload fileUpload = new MixedFileUpload(name, filename, contentType,
|
||||
contentTransferEncoding, charset, size, minSize);
|
||||
List<HttpData> fileToDelete = getList(request);
|
||||
|
|
|
@ -914,7 +914,8 @@ public class HttpPostRequestDecoder {
|
|||
if (newline.equals(delimiter)) {
|
||||
currentStatus = dispositionStatus;
|
||||
return decodeMultipart(dispositionStatus);
|
||||
} else if (newline.equals(delimiter + "--")) {
|
||||
}
|
||||
if (newline.equals(delimiter + "--")) {
|
||||
// CLOSEDELIMITER or MIXED CLOSEDELIMITER found
|
||||
currentStatus = closeDelimiterStatus;
|
||||
if (currentStatus == MultiPartStatus.HEADERDELIMITER) {
|
||||
|
@ -1932,7 +1933,8 @@ public class HttpPostRequestDecoder {
|
|||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 2);
|
||||
return false;
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
}
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return true;
|
||||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
|
||||
|
|
|
@ -303,9 +303,11 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||
// fragmented
|
||||
if (frameOpcode == OPCODE_PING) {
|
||||
return new PingWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_PONG) {
|
||||
}
|
||||
if (frameOpcode == OPCODE_PONG) {
|
||||
return new PongWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_CLOSE) {
|
||||
}
|
||||
if (frameOpcode == OPCODE_CLOSE) {
|
||||
checkCloseFrameBody(channel, framePayload);
|
||||
receivedClosingHandshake = true;
|
||||
return new CloseWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
|
|
|
@ -52,9 +52,11 @@ public enum WebSocketVersion {
|
|||
public String toHttpHeaderValue() {
|
||||
if (this == V00) {
|
||||
return "0";
|
||||
} else if (this == V08) {
|
||||
}
|
||||
if (this == V08) {
|
||||
return "8";
|
||||
} else if (this == V13) {
|
||||
}
|
||||
if (this == V13) {
|
||||
return "13";
|
||||
}
|
||||
throw new IllegalStateException("Unknown web socket version: " + this);
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.codec.oneone;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelDownstreamHandler;
|
||||
|
@ -27,6 +25,8 @@ import org.jboss.netty.channel.MessageEvent;
|
|||
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
/**
|
||||
* Transforms a write request into another write request. A typical setup for
|
||||
* TCP/IP would be:
|
||||
|
@ -66,7 +66,8 @@ public abstract class OneToOneEncoder implements ChannelDownstreamHandler {
|
|||
Object encodedMessage = encode(ctx, e.getChannel(), originalMessage);
|
||||
if (originalMessage == encodedMessage) {
|
||||
return false;
|
||||
} else if (encodedMessage != null) {
|
||||
}
|
||||
if (encodedMessage != null) {
|
||||
write(ctx, e.getFuture(), encodedMessage, e.getRemoteAddress());
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.codec.replay;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler;
|
||||
|
@ -26,6 +24,8 @@ import org.jboss.netty.channel.ChannelStateEvent;
|
|||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
/**
|
||||
* A specialized variation of {@link FrameDecoder} which enables implementation
|
||||
* of a non-blocking decoder in the blocking I/O paradigm.
|
||||
|
@ -546,10 +546,9 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
|||
ChannelBuffer cumulation = this.cumulation;
|
||||
if (!needsCleanup) {
|
||||
return;
|
||||
} else {
|
||||
needsCleanup = false;
|
||||
}
|
||||
|
||||
needsCleanup = false;
|
||||
replayable.terminate();
|
||||
|
||||
if (cumulation != null && cumulation.readable()) {
|
||||
|
|
|
@ -15,11 +15,6 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.ChannelDownstreamHandler;
|
||||
|
@ -29,6 +24,11 @@ import org.jboss.netty.channel.ChannelStateEvent;
|
|||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
/**
|
||||
* Encodes a SPDY Data or Control Frame into a {@link ChannelBuffer}.
|
||||
*/
|
||||
|
@ -118,7 +118,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdySynStreamFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdySynStreamFrame) {
|
||||
|
||||
synchronized (headerBlockCompressor) {
|
||||
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
||||
|
@ -162,7 +164,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
}
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdySynReplyFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdySynReplyFrame) {
|
||||
|
||||
synchronized (headerBlockCompressor) {
|
||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||
|
@ -209,7 +213,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdySettingsFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdySettingsFrame) {
|
||||
|
||||
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
|
||||
byte flags = spdySettingsFrame.clearPreviouslyPersistedSettings() ?
|
||||
|
@ -250,7 +256,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdyNoOpFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdyNoOpFrame) {
|
||||
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE);
|
||||
|
@ -260,7 +268,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdyPingFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdyPingFrame) {
|
||||
|
||||
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
|
@ -272,7 +282,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdyGoAwayFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdyGoAwayFrame) {
|
||||
|
||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||
int length = version < 3 ? 4 : 8;
|
||||
|
@ -288,7 +300,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
Channels.write(ctx, e.getFuture(), frame, e.getRemoteAddress());
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdyHeadersFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdyHeadersFrame) {
|
||||
|
||||
synchronized (headerBlockCompressor) {
|
||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||
|
@ -318,8 +332,9 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
|||
}
|
||||
return;
|
||||
|
||||
} else if (msg instanceof SpdyWindowUpdateFrame) {
|
||||
}
|
||||
|
||||
if (msg instanceof SpdyWindowUpdateFrame) {
|
||||
SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + 8);
|
||||
|
|
|
@ -65,9 +65,11 @@ public class CIDR4 extends CIDR {
|
|||
}
|
||||
if (net < addressInt) {
|
||||
return 1;
|
||||
} else if (net > addressInt) {
|
||||
}
|
||||
if (net > addressInt) {
|
||||
return -1;
|
||||
} else if (arg.cidrMask < cidrMask) {
|
||||
}
|
||||
if (arg.cidrMask < cidrMask) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
|
@ -78,9 +80,11 @@ public class CIDR4 extends CIDR {
|
|||
}
|
||||
if (o.addressInt < addressInt) {
|
||||
return 1;
|
||||
} else if (o.addressInt > addressInt) {
|
||||
}
|
||||
if (o.addressInt > addressInt) {
|
||||
return -1;
|
||||
} else if (o.cidrMask < cidrMask) {
|
||||
}
|
||||
if (o.cidrMask < cidrMask) {
|
||||
// greater Mask means less IpAddresses so -1
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.ipfilter;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CIDR6 extends CIDR {
|
||||
|
@ -73,7 +73,8 @@ public class CIDR6 extends CIDR {
|
|||
if (res == 0) {
|
||||
if (arg.cidrMask == cidrMask) {
|
||||
return 0;
|
||||
} else if (arg.cidrMask < cidrMask) {
|
||||
}
|
||||
if (arg.cidrMask < cidrMask) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -243,9 +243,11 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
|||
}
|
||||
if (o.subnet < subnet) {
|
||||
return 1;
|
||||
} else if (o.subnet > subnet) {
|
||||
}
|
||||
if (o.subnet > subnet) {
|
||||
return -1;
|
||||
} else if (o.cidrMask < cidrMask) {
|
||||
}
|
||||
if (o.cidrMask < cidrMask) {
|
||||
// greater Mask means less IpAddresses so -1
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -15,15 +15,6 @@
|
|||
*/
|
||||
package org.jboss.netty.handler.queue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
|
@ -39,6 +30,15 @@ import org.jboss.netty.channel.SimpleChannelHandler;
|
|||
import org.jboss.netty.channel.socket.nio.NioSocketChannelConfig;
|
||||
import org.jboss.netty.util.HashedWheelTimer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Emulates buffered write operation. This handler stores all write requests
|
||||
* into an unbounded {@link Queue} and flushes them to the downstream when
|
||||
|
@ -297,7 +297,8 @@ public class BufferedWriteHandler extends SimpleChannelHandler implements LifeCy
|
|||
if (size == 1) {
|
||||
ctx.sendDownstream(pendingWrites.remove(0));
|
||||
return pendingWrites;
|
||||
} else if (size == 0) {
|
||||
}
|
||||
if (size == 0) {
|
||||
return pendingWrites;
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,8 @@ final class Deflate {
|
|||
nextlen = tree[(n + 1) * 2 + 1];
|
||||
if (++ count < max_count && curlen == nextlen) {
|
||||
continue;
|
||||
} else if (count < min_count) {
|
||||
}
|
||||
if (count < min_count) {
|
||||
bl_tree[curlen * 2] += count;
|
||||
} else if (curlen != 0) {
|
||||
if (curlen != prevlen) {
|
||||
|
@ -458,7 +459,8 @@ final class Deflate {
|
|||
nextlen = tree[(n + 1) * 2 + 1];
|
||||
if (++ count < max_count && curlen == nextlen) {
|
||||
continue;
|
||||
} else if (count < min_count) {
|
||||
}
|
||||
if (count < min_count) {
|
||||
do {
|
||||
send_code(curlen, bl_tree);
|
||||
} while (-- count != 0);
|
||||
|
|
|
@ -303,7 +303,8 @@ final class Inflate {
|
|||
if (z.istate.wrapperType == WrapperType.NONE) {
|
||||
z.istate.mode = DONE;
|
||||
break;
|
||||
} else if (z.istate.wrapperType == WrapperType.ZLIB) {
|
||||
}
|
||||
if (z.istate.wrapperType == WrapperType.ZLIB) {
|
||||
z.istate.mode = CHECK4;
|
||||
} else if (z.istate.wrapperType == WrapperType.GZIP) {
|
||||
gzipCRC32 = 0;
|
||||
|
@ -317,7 +318,7 @@ final class Inflate {
|
|||
z.istate.marker = 0;
|
||||
break;
|
||||
}
|
||||
case CHECK4:
|
||||
case CHECK4:
|
||||
if (z.avail_in == 0) {
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user