Fix inspector warnings introduced by recent mergences
This commit is contained in:
parent
818a7b42a3
commit
6208c62888
@ -54,14 +54,17 @@ public abstract class AbstractByteBufAllocator implements ByteBufAllocator {
|
||||
return heapBuffer(initialCapacity, maxCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf heapBuffer() {
|
||||
return heapBuffer(256, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf heapBuffer(int initialCapacity) {
|
||||
return buffer(initialCapacity, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf heapBuffer(int initialCapacity, int maxCapacity) {
|
||||
if (initialCapacity == 0 && maxCapacity == 0) {
|
||||
return emptyBuf;
|
||||
@ -69,14 +72,17 @@ public abstract class AbstractByteBufAllocator implements ByteBufAllocator {
|
||||
return newHeapBuffer(initialCapacity, maxCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf directBuffer() {
|
||||
return directBuffer(256, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf directBuffer(int initialCapacity) {
|
||||
return directBuffer(initialCapacity, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf directBuffer(int initialCapacity, int maxCapacity) {
|
||||
if (initialCapacity == 0 && maxCapacity == 0) {
|
||||
return emptyBuf;
|
||||
|
@ -31,13 +31,6 @@ public final class SocksAuthRequest extends SocksRequest {
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @throws NullPointerException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public SocksAuthRequest(String username, String password) {
|
||||
super(SocksRequestType.AUTH);
|
||||
if (username == null) {
|
||||
|
@ -45,7 +45,7 @@ public class SocksAuthRequestDecoder extends ReplayingDecoder<SocksRequest, Sock
|
||||
public SocksRequest decode(ChannelHandlerContext ctx, ByteBuf byteBuf) throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksMessage.ProtocolVersion.fromByte((byte) byteBuf.readByte());
|
||||
version = SocksMessage.ProtocolVersion.fromByte(byteBuf.readByte());
|
||||
if (version != SocksMessage.ProtocolVersion.SOCKS5) {
|
||||
break;
|
||||
}
|
||||
|
@ -33,15 +33,6 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
private final String host;
|
||||
private final int port;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cmdType
|
||||
* @param addressType
|
||||
* @param host
|
||||
* @param port
|
||||
* @throws NullPointerException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public SocksCmdRequest(CmdType cmdType, AddressType addressType, String host, int port) {
|
||||
super(SocksRequestType.CMD);
|
||||
if (cmdType == null) {
|
||||
@ -72,7 +63,7 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
case UNKNOWN:
|
||||
break;
|
||||
}
|
||||
if ((port < 0) && (port >= 65535)) {
|
||||
if (port < 0 && port >= 65535) {
|
||||
throw new IllegalArgumentException(port + " is not in bounds 0 < x < 65536");
|
||||
}
|
||||
this.cmdType = cmdType;
|
||||
|
@ -34,12 +34,6 @@ public final class SocksCmdResponse extends SocksResponse {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cmdStatus
|
||||
* @param addressType
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
public SocksCmdResponse(CmdStatus cmdStatus, AddressType addressType) {
|
||||
super(SocksResponseType.CMD);
|
||||
if (cmdStatus == null) {
|
||||
|
@ -32,10 +32,10 @@ final class SocksCommonUtils {
|
||||
}
|
||||
|
||||
public static String intToIp(int i) {
|
||||
return new StringBuilder().append((i >> FIRST_ADDRESS_OCTET_SHIFT) & XOR_DEFAULT_VALUE).append(".")
|
||||
.append((i >> SECOND_ADDRESS_OCTET_SHIFT) & XOR_DEFAULT_VALUE).append(".")
|
||||
.append((i >> THIRD_ADDRESS_OCTET_SHIFT) & XOR_DEFAULT_VALUE).append(".")
|
||||
.append(i & XOR_DEFAULT_VALUE).toString();
|
||||
return String.valueOf(i >> FIRST_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' +
|
||||
(i >> SECOND_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' +
|
||||
(i >> THIRD_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' +
|
||||
(i & XOR_DEFAULT_VALUE);
|
||||
}
|
||||
|
||||
private static final char[] ipv6conseqZeroFiller = {':', ':'};
|
||||
@ -64,7 +64,7 @@ final class SocksCommonUtils {
|
||||
cmprHextet = hextet;
|
||||
cmprSize = size;
|
||||
}
|
||||
hextet = (curByte / 2) + 1;
|
||||
hextet = curByte / 2 + 1;
|
||||
}
|
||||
if (cmprHextet == -1 || cmprSize < 2) {
|
||||
//No compression can be applied
|
||||
@ -93,8 +93,8 @@ final class SocksCommonUtils {
|
||||
private static void ipv6toStr(StringBuilder sb, byte[] src,
|
||||
int fromHextet, int toHextet) {
|
||||
for (int i = fromHextet; i < toHextet; i++) {
|
||||
sb.append(Integer.toHexString(((src[i << 1] << 8) & 0xff00)
|
||||
| (src[(i << 1) + 1] & 0xff)));
|
||||
sb.append(Integer.toHexString(src[i << 1] << 8 & 0xff00
|
||||
| src[(i << 1) + 1] & 0xff));
|
||||
if (i < toHextet - 1) {
|
||||
sb.append(ipv6hextetSeparator);
|
||||
}
|
||||
|
@ -26,11 +26,6 @@ import io.netty.buffer.ByteBuf;
|
||||
public final class SocksInitResponse extends SocksResponse {
|
||||
private final AuthScheme authScheme;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param authScheme
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
public SocksInitResponse(AuthScheme authScheme) {
|
||||
super(SocksResponseType.INIT);
|
||||
if (authScheme == null) {
|
||||
|
@ -29,12 +29,7 @@ public abstract class SocksMessage {
|
||||
private final MessageType messageType;
|
||||
private final ProtocolVersion protocolVersion = ProtocolVersion.SOCKS5;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param messageType
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
public SocksMessage(MessageType messageType) {
|
||||
protected SocksMessage(MessageType messageType) {
|
||||
if (messageType == null) {
|
||||
throw new NullPointerException("messageType");
|
||||
}
|
||||
@ -64,7 +59,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private AuthScheme(byte b) {
|
||||
AuthScheme(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -90,7 +85,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private CmdType(byte b) {
|
||||
CmdType(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -116,7 +111,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private AddressType(byte b) {
|
||||
AddressType(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -140,7 +135,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private AuthStatus(byte b) {
|
||||
AuthStatus(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -172,7 +167,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private CmdStatus(byte b) {
|
||||
CmdStatus(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -197,7 +192,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private ProtocolVersion(byte b) {
|
||||
ProtocolVersion(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,7 @@ package io.netty.codec.socks;
|
||||
public abstract class SocksRequest extends SocksMessage {
|
||||
private final SocksRequestType socksRequestType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param socksRequestType
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
public SocksRequest(SocksRequestType socksRequestType) {
|
||||
protected SocksRequest(SocksRequestType socksRequestType) {
|
||||
super(MessageType.REQUEST);
|
||||
if (socksRequestType == null) {
|
||||
throw new NullPointerException("socksRequestType");
|
||||
|
@ -27,12 +27,7 @@ package io.netty.codec.socks;
|
||||
public abstract class SocksResponse extends SocksMessage {
|
||||
private final SocksResponseType socksResponseType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param socksResponseType
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
public SocksResponse(SocksResponseType socksResponseType) {
|
||||
protected SocksResponse(SocksResponseType socksResponseType) {
|
||||
super(MessageType.RESPONSE);
|
||||
if (socksResponseType == null) {
|
||||
throw new NullPointerException("socksResponseType");
|
||||
|
@ -18,8 +18,8 @@ package io.netty.codec.socks;
|
||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocksAuthRequestDecoderTest {
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SocksAuthRequestDecoderTest.class);
|
||||
@ -32,8 +32,8 @@ public class SocksAuthRequestDecoderTest {
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
msg = (SocksAuthRequest) embedder.readInbound();
|
||||
assertTrue(msg.getUsername().equals(username));
|
||||
assertTrue(msg.getUsername().equals(password));
|
||||
assertEquals(msg.getUsername(), username);
|
||||
assertEquals(msg.getUsername(), password);
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
}
|
||||
|
@ -18,19 +18,19 @@ package io.netty.codec.socks;
|
||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocksAuthResponseDecoderTest {
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SocksAuthResponseDecoderTest.class);
|
||||
private void testSocksAuthResponseDecoderWithDifferentParams(SocksMessage.AuthStatus authStatus){
|
||||
private static void testSocksAuthResponseDecoderWithDifferentParams(SocksMessage.AuthStatus authStatus){
|
||||
logger.debug("Testing SocksAuthResponseDecoder with authStatus: "+ authStatus);
|
||||
SocksAuthResponse msg = new SocksAuthResponse(authStatus);
|
||||
SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder();
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
msg = (SocksAuthResponse) embedder.readInbound();
|
||||
assertTrue(msg.getAuthStatus().equals(authStatus));
|
||||
assertSame(msg.getAuthStatus(), authStatus);
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocksCmdRequestDecoderTest {
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SocksCmdRequestDecoderTest.class);
|
||||
|
||||
private void testSocksCmdRequestDecoderWithDifferentParams(SocksMessage.CmdType cmdType, SocksMessage.AddressType addressType, String host, int port) {
|
||||
private static void testSocksCmdRequestDecoderWithDifferentParams(SocksMessage.CmdType cmdType, SocksMessage.AddressType addressType, String host, int port) {
|
||||
logger.debug("Testing cmdType: " + cmdType + " addressType: " + addressType + " host: " + host + " port: " + port);
|
||||
SocksCmdRequest msg = new SocksCmdRequest(cmdType, addressType, host, port);
|
||||
SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder();
|
||||
@ -35,10 +35,10 @@ public class SocksCmdRequestDecoderTest {
|
||||
assertTrue(embedder.readInbound() instanceof UnknownSocksRequest);
|
||||
} else {
|
||||
msg = (SocksCmdRequest) embedder.readInbound();
|
||||
assertTrue(msg.getCmdType().equals(cmdType));
|
||||
assertTrue(msg.getAddressType().equals(addressType));
|
||||
assertTrue(msg.getHost().equals(host));
|
||||
assertTrue(msg.getPort() == port);
|
||||
assertSame(msg.getCmdType(), cmdType);
|
||||
assertSame(msg.getAddressType(), addressType);
|
||||
assertEquals(msg.getHost(), host);
|
||||
assertEquals(msg.getPort(), port);
|
||||
}
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ package io.netty.codec.socks;
|
||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocksCmdResponseDecoderTest {
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SocksCmdResponseDecoderTest.class);
|
||||
|
||||
private void testSocksCmdResponseDecoderWithDifferentParams(SocksMessage.CmdStatus cmdStatus, SocksMessage.AddressType addressType){
|
||||
private static void testSocksCmdResponseDecoderWithDifferentParams(SocksMessage.CmdStatus cmdStatus, SocksMessage.AddressType addressType){
|
||||
logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType);
|
||||
SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType);
|
||||
SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder();
|
||||
@ -33,8 +33,8 @@ public class SocksCmdResponseDecoderTest {
|
||||
if (addressType == SocksMessage.AddressType.UNKNOWN){
|
||||
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
|
||||
} else {
|
||||
msg = (SocksCmdResponse) embedder.readInbound();
|
||||
assertTrue(((SocksCmdResponse) msg).getCmdStatus().equals(cmdStatus));
|
||||
msg = (SocksResponse) embedder.readInbound();
|
||||
assertEquals(((SocksCmdResponse) msg).getCmdStatus(), cmdStatus);
|
||||
}
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
@ -168,7 +168,9 @@ public class DelimiterBasedFrameDecoder extends ByteToMessageDecoder<Object> {
|
||||
}
|
||||
if (delimiters.length == 0) {
|
||||
throw new IllegalArgumentException("empty delimiters");
|
||||
} else if (isLineBased(delimiters) && !isSubclass()) {
|
||||
}
|
||||
|
||||
if (isLineBased(delimiters) && !isSubclass()) {
|
||||
lineBasedDecoder = new LineBasedFrameDecoder(maxFrameLength, stripDelimiter, failFast);
|
||||
this.delimiters = null;
|
||||
} else {
|
||||
@ -203,7 +205,7 @@ public class DelimiterBasedFrameDecoder extends ByteToMessageDecoder<Object> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return <code>true</code> if the current instance is a subclass of DelimiterBasedFrameDecoder
|
||||
* Return {@code true} if the current instance is a subclass of DelimiterBasedFrameDecoder
|
||||
*/
|
||||
private boolean isSubclass() {
|
||||
return this.getClass() != DelimiterBasedFrameDecoder.class;
|
||||
|
@ -18,7 +18,6 @@ package io.netty.example.socksproxy;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
public interface CallbackNotifier {
|
||||
void onSuccess(final ChannelHandlerContext outboundCtx);
|
||||
|
||||
void onFailure(final ChannelHandlerContext outboundCtx, final Throwable cause);
|
||||
void onSuccess(ChannelHandlerContext outboundCtx);
|
||||
void onFailure(ChannelHandlerContext outboundCtx, Throwable cause);
|
||||
}
|
||||
|
@ -16,14 +16,13 @@
|
||||
package io.netty.example.socksproxy;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.codec.socks.SocksCmdRequest;
|
||||
import io.netty.codec.socks.SocksCmdResponse;
|
||||
@ -48,17 +47,20 @@ public final class SocksServerConnectHandler extends ChannelInboundMessageHandle
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final SocksCmdRequest request) throws Exception {
|
||||
CallbackNotifier cb = new CallbackNotifier() {
|
||||
@Override
|
||||
public void onSuccess(final ChannelHandlerContext outboundCtx) {
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.SUCCESS, request.getAddressType()))
|
||||
.addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture channelFuture) throws Exception {
|
||||
ctx.pipeline().remove(SocksServerConnectHandler.getName());
|
||||
ctx.pipeline().remove(getName());
|
||||
outboundCtx.channel().pipeline().addLast(new RelayHandler(ctx.channel()));
|
||||
ctx.channel().pipeline().addLast(new RelayHandler(outboundCtx.channel()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(ChannelHandlerContext outboundCtx, Throwable cause) {
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.FAILURE, request.getAddressType()));
|
||||
SocksServerUtils.closeOnFlush(ctx.channel());
|
||||
@ -72,7 +74,7 @@ public final class SocksServerConnectHandler extends ChannelInboundMessageHandle
|
||||
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||
.handler(new DirectClientInitializer(cb))
|
||||
.remoteAddress(request.getHost(), request.getPort());
|
||||
ChannelFuture f = b.connect();
|
||||
b.connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,8 +24,6 @@ import io.netty.codec.socks.SocksMessage;
|
||||
import io.netty.codec.socks.SocksRequest;
|
||||
import io.netty.codec.socks.SocksAuthResponse;
|
||||
import io.netty.codec.socks.SocksCmdRequest;
|
||||
import io.netty.codec.socks.SocksCmdResponse;
|
||||
|
||||
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
|
@ -22,12 +22,8 @@ import io.netty.codec.socks.SocksInitRequestDecoder;
|
||||
import io.netty.codec.socks.SocksMessageEncoder;
|
||||
|
||||
public final class SocksServerInitializer extends ChannelInitializer<SocketChannel> {
|
||||
private SocksMessageEncoder socksMessageEncoder = new SocksMessageEncoder();
|
||||
private SocksServerHandler socksServerHandler = new SocksServerHandler();
|
||||
|
||||
public SocksServerInitializer() {
|
||||
super();
|
||||
}
|
||||
private final SocksMessageEncoder socksMessageEncoder = new SocksMessageEncoder();
|
||||
private final SocksServerHandler socksServerHandler = new SocksServerHandler();
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel socketChannel) throws Exception {
|
||||
|
@ -32,7 +32,6 @@ import java.io.IOException;
|
||||
import java.nio.channels.Channels;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChunkedWriteHandlerTest {
|
||||
|
@ -70,17 +70,19 @@ public class DefaultChannelPipelineTest {
|
||||
|
||||
final String prefixX = "x";
|
||||
for (int i = 0; i < handlerNum; i++) {
|
||||
if (i % 2 == 0)
|
||||
if (i % 2 == 0) {
|
||||
pipeline.addFirst(prefixX + String.valueOf(i), handlers1[i]);
|
||||
else
|
||||
} else {
|
||||
pipeline.addLast(prefixX + String.valueOf(i), handlers1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < handlerNum; i++) {
|
||||
if (i % 2 != 0)
|
||||
if (i % 2 != 0) {
|
||||
pipeline.addBefore(prefixX + String.valueOf(i), String.valueOf(i), handlers2[i]);
|
||||
else
|
||||
} else {
|
||||
pipeline.addAfter(prefixX + String.valueOf(i), String.valueOf(i), handlers2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
verifyContextNumber(pipeline, handlerNum * 2);
|
||||
@ -115,17 +117,18 @@ public class DefaultChannelPipelineTest {
|
||||
|
||||
private int next(DefaultChannelHandlerContext ctx) {
|
||||
DefaultChannelHandlerContext next = ctx.next;
|
||||
if (next == null)
|
||||
if (next == null) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return toInt(next.name());
|
||||
}
|
||||
|
||||
private int toInt(String name) {
|
||||
private static int toInt(String name) {
|
||||
return Integer.parseInt(name);
|
||||
}
|
||||
|
||||
private void verifyContextNumber(DefaultChannelPipeline pipeline, int expectedNumber) {
|
||||
private static void verifyContextNumber(DefaultChannelPipeline pipeline, int expectedNumber) {
|
||||
DefaultChannelHandlerContext ctx = (DefaultChannelHandlerContext) pipeline.firstContext();
|
||||
int handlerNumber = 0;
|
||||
while (ctx != null) {
|
||||
@ -139,8 +142,9 @@ public class DefaultChannelPipelineTest {
|
||||
assert num > 0;
|
||||
|
||||
ChannelHandler[] handlers = new ChannelHandler[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
for (int i = 0; i < num; i++) {
|
||||
handlers[i] = newHandler();
|
||||
}
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user