Fix various inspection warnings
This commit is contained in:
parent
0365b25e5b
commit
560ccc019c
@ -32,7 +32,6 @@ import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@ -297,8 +296,8 @@ abstract class AbstractNioSelector implements NioSelector {
|
||||
// process one time again
|
||||
processTaskQueue();
|
||||
|
||||
for (Iterator<SelectionKey> i = selector.keys().iterator(); i.hasNext();) {
|
||||
close(i.next());
|
||||
for (SelectionKey k: selector.keys()) {
|
||||
close(k);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -74,7 +74,7 @@ public final class NioClientBoss extends AbstractNioSelector implements Boss {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(Selector selector) throws IOException {
|
||||
protected void process(Selector selector) {
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
|
||||
// Handle connection timeout every 10 milliseconds approximately.
|
||||
|
@ -35,7 +35,7 @@ public class NioClientBossPool extends AbstractNioBossPool<NioClientBoss> {
|
||||
* @param bossExecutor the Executor to use for server the {@link NioClientBoss}
|
||||
* @param bossCount the number of {@link NioClientBoss} instances this {@link NioClientBossPool} will hold
|
||||
* @param timer the Timer to use for handle connect timeouts
|
||||
* @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use <code>null</code>
|
||||
* @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
|
||||
* if you not want to set one explicit.
|
||||
*/
|
||||
public NioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer determiner) {
|
||||
|
@ -18,14 +18,15 @@ package org.jboss.netty.channel.socket.nio;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
|
||||
import java.nio.channels.Selector;
|
||||
|
||||
|
||||
public interface NioSelector extends Runnable {
|
||||
|
||||
void register(Channel channel, ChannelFuture future);
|
||||
|
||||
/**
|
||||
* Replaces the current {@link java.nio.channels.Selector} with a
|
||||
* new {@link java.nio.channels.Selector} to work around the infamous epoll 100% CPU
|
||||
* Replaces the current {@link Selector} with a new {@link Selector} to work around the infamous epoll 100% CPU
|
||||
* bug.
|
||||
*/
|
||||
void rebuildSelector();
|
||||
|
@ -16,11 +16,13 @@
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
|
||||
import java.nio.channels.Selector;
|
||||
|
||||
public interface NioSelectorPool {
|
||||
|
||||
/**
|
||||
* Replaces the current {@link java.nio.channels.Selector}s of the {@link Boss}es with new
|
||||
* {@link java.nio.channels.Selector}s to work around the infamous epoll 100% CPU bug.
|
||||
* Replaces the current {@link Selector}s of the {@link Boss}es with new {@link Selector}s to work around the
|
||||
* infamous epoll 100% CPU bug.
|
||||
*/
|
||||
void rebuildSelectors();
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class NioServerBossPool extends AbstractNioBossPool<NioServerBoss> {
|
||||
*
|
||||
* @param bossExecutor the {@link Executor} to use for server the {@link NioServerBoss}
|
||||
* @param bossCount the number of {@link NioServerBoss} instances this {@link NioServerBossPool} will hold
|
||||
* @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use <code>null</code>
|
||||
* @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
|
||||
* if you not want to set one explicit.
|
||||
*/
|
||||
public NioServerBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer determiner) {
|
||||
|
@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.oio;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
@ -27,6 +23,10 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
||||
import org.jboss.netty.channel.socket.ServerSocketChannelFactory;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
/**
|
||||
* A {@link ServerSocketChannelFactory} which creates a server-side blocking
|
||||
* I/O based {@link ServerSocketChannel}. It utilizes the good old blocking
|
||||
@ -99,7 +99,7 @@ public class OioServerSocketChannelFactory implements ServerSocketChannelFactory
|
||||
*/
|
||||
public OioServerSocketChannelFactory() {
|
||||
this(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
|
||||
this.shutdownExecutor = true;
|
||||
shutdownExecutor = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
|
||||
private boolean discardingTooLongFrame;
|
||||
private int tooLongFrameLength;
|
||||
/** Set only when decoding with "\n" and "\r\n" as the delimiter. */
|
||||
private LineBasedFrameDecoder lineBasedDecoder;
|
||||
private final LineBasedFrameDecoder lineBasedDecoder;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
@ -173,7 +173,9 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
|
||||
}
|
||||
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 {
|
||||
@ -207,10 +209,10 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return getClass() != DelimiterBasedFrameDecoder.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -381,7 +381,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* Decodes the received packets so far into a frame.
|
||||
*
|
||||
* If an sub-class wants to extract a frame out of the buffer it should use
|
||||
* the {@link #extractFrame(org.jboss.netty.buffer.ChannelBuffer, int, int)} method,
|
||||
* the {@link #extractFrame(ChannelBuffer, int, int)} method,
|
||||
* to make optimizations easier later.
|
||||
*
|
||||
* @param ctx the context of this handler
|
||||
|
@ -16,11 +16,9 @@
|
||||
package org.jboss.netty.handler.codec.frame;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
|
||||
|
||||
/**
|
||||
* A decoder that splits the received {@link ChannelBuffer}s dynamically by the
|
||||
|
@ -15,15 +15,6 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
@ -31,13 +22,17 @@ import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class AbstractDatagramTest {
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public abstract class AbstractDatagramTest {
|
||||
|
||||
protected abstract DatagramChannelFactory newServerSocketChannelFactory(Executor executor);
|
||||
protected abstract DatagramChannelFactory newClientSocketChannelFactory(Executor executor);
|
||||
|
@ -24,24 +24,20 @@ import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import org.jboss.netty.util.TestUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UnsupportedMessageTest {
|
||||
|
||||
|
||||
// Test for https://github.com/netty/netty/issues/734
|
||||
@Test()
|
||||
@Test
|
||||
public void testUnsupported() throws Throwable {
|
||||
ServerBootstrap sb = new ServerBootstrap(new NioServerSocketChannelFactory());
|
||||
ClientBootstrap cb = new ClientBootstrap(new NioClientSocketChannelFactory());
|
||||
|
@ -17,7 +17,6 @@ package org.jboss.netty.handler.codec.frame;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.embedder.CodecEmbedderException;
|
||||
import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
|
@ -15,16 +15,6 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.string;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.jboss.netty.bootstrap.ClientBootstrap;
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
@ -39,11 +29,17 @@ import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
import org.jboss.netty.util.TestUtil;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public abstract class AbstractSocketStringEchoTest {
|
||||
|
||||
static final Random random = new Random();
|
||||
|
@ -15,16 +15,14 @@
|
||||
*/
|
||||
package org.jboss.netty.util;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.security.Permission;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ThreadRenamingRunnableTest {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user