Fix various checkstyle violations
Backported from master
This commit is contained in:
parent
53fede511c
commit
e2109b236b
@ -310,7 +310,7 @@ public class Bootstrap implements ExternalResourceReleasable {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This method simply delegates the call to
|
||||
* This method simply delegates the call to
|
||||
* {@link ChannelFactory#releaseExternalResources()}.
|
||||
*/
|
||||
public void releaseExternalResources() {
|
||||
|
@ -47,7 +47,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
||||
*
|
||||
* <pre>
|
||||
* {@link ChannelBuffer} buffer = ...;
|
||||
* for (int i = 0; i < buffer.capacity(); i ++</strong>) {
|
||||
* for (int i = 0; i < buffer.capacity(); i ++) {
|
||||
* byte b = buffer.getByte(i);
|
||||
* System.out.println((char) b);
|
||||
* }
|
||||
|
@ -42,7 +42,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a {@code NUL (0x00)} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NUL = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NUL = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == 0;
|
||||
}
|
||||
@ -51,7 +51,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a non-{@code NUL (0x00)} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_NUL = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NOT_NUL = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != 0;
|
||||
}
|
||||
@ -60,7 +60,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a {@code CR ('\r')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder CR = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder CR = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == '\r';
|
||||
}
|
||||
@ -69,7 +69,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a non-{@code CR ('\r')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_CR = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NOT_CR = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != '\r';
|
||||
}
|
||||
@ -78,7 +78,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a {@code LF ('\n')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder LF = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder LF = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) == '\n';
|
||||
}
|
||||
@ -87,7 +87,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a non-{@code LF ('\n')} byte.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_LF = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NOT_LF = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
return buffer.getByte(guessedIndex) != '\n';
|
||||
}
|
||||
@ -96,7 +96,7 @@ public interface ChannelBufferIndexFinder {
|
||||
/**
|
||||
* Index finder which locates a {@code CR ('\r')} or {@code LF ('\n')}.
|
||||
*/
|
||||
static ChannelBufferIndexFinder CRLF = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder CRLF = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b == '\r' || b == '\n';
|
||||
@ -107,7 +107,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a byte which is neither a {@code CR ('\r')}
|
||||
* nor a {@code LF ('\n')}.
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_CRLF = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NOT_CRLF = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b != '\r' && b != '\n';
|
||||
@ -118,7 +118,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a linear whitespace
|
||||
* ({@code ' '} and {@code '\t'}).
|
||||
*/
|
||||
static ChannelBufferIndexFinder LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b == ' ' || b == '\t';
|
||||
@ -129,7 +129,7 @@ public interface ChannelBufferIndexFinder {
|
||||
* Index finder which locates a byte which is not a linear whitespace
|
||||
* (neither {@code ' '} nor {@code '\t'}).
|
||||
*/
|
||||
static ChannelBufferIndexFinder NOT_LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
ChannelBufferIndexFinder NOT_LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||
byte b = buffer.getByte(guessedIndex);
|
||||
return b != ' ' && b != '\t';
|
||||
|
@ -85,7 +85,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
* @apiviz.landmark
|
||||
* @apiviz.has org.jboss.netty.buffer.ChannelBuffer oneway - - creates
|
||||
*/
|
||||
public class ChannelBuffers {
|
||||
public final class ChannelBuffers {
|
||||
|
||||
/**
|
||||
* Big endian byte order.
|
||||
|
@ -57,9 +57,9 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
||||
private final Object bigEndianLock = new Object();
|
||||
private final Object littleEndianLock = new Object();
|
||||
private final int preallocatedBufferCapacity;
|
||||
private ChannelBuffer preallocatedBigEndianBuffer = null;
|
||||
private ChannelBuffer preallocatedBigEndianBuffer;
|
||||
private int preallocatedBigEndianBufferPosition;
|
||||
private ChannelBuffer preallocatedLittleEndianBuffer = null;
|
||||
private ChannelBuffer preallocatedLittleEndianBuffer;
|
||||
private int preallocatedLittleEndianBufferPosition;
|
||||
|
||||
/**
|
||||
|
@ -112,25 +112,25 @@ public interface Channel extends Comparable<Channel> {
|
||||
* The {@link #getInterestOps() interestOps} value which tells that only
|
||||
* read operation has been suspended.
|
||||
*/
|
||||
static int OP_NONE = 0;
|
||||
int OP_NONE = 0;
|
||||
|
||||
/**
|
||||
* The {@link #getInterestOps() interestOps} value which tells that neither
|
||||
* read nor write operation has been suspended.
|
||||
*/
|
||||
static int OP_READ = 1;
|
||||
int OP_READ = 1;
|
||||
|
||||
/**
|
||||
* The {@link #getInterestOps() interestOps} value which tells that both
|
||||
* read and write operation has been suspended.
|
||||
*/
|
||||
static int OP_WRITE = 4;
|
||||
int OP_WRITE = 4;
|
||||
|
||||
/**
|
||||
* The {@link #getInterestOps() interestOps} value which tells that only
|
||||
* write operation has been suspended.
|
||||
*/
|
||||
static int OP_READ_WRITE = OP_READ | OP_WRITE;
|
||||
int OP_READ_WRITE = OP_READ | OP_WRITE;
|
||||
|
||||
/**
|
||||
* Returns the unique integer ID of this channel.
|
||||
|
@ -55,7 +55,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
||||
*
|
||||
* <table border="1" cellspacing="0" cellpadding="6">
|
||||
* <tr>
|
||||
* <th>Event name</th></th><th>Event type and condition</th><th>Meaning</th>
|
||||
* <th>Event name</th><th>Event type and condition</th><th>Meaning</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code "messageReceived"}</td>
|
||||
|
@ -36,7 +36,7 @@ public interface ChannelFutureListener extends EventListener {
|
||||
* A {@link ChannelFutureListener} that closes the {@link Channel} which is
|
||||
* associated with the specified {@link ChannelFuture}.
|
||||
*/
|
||||
static ChannelFutureListener CLOSE = new ChannelFutureListener() {
|
||||
ChannelFutureListener CLOSE = new ChannelFutureListener() {
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
future.getChannel().close();
|
||||
}
|
||||
@ -46,7 +46,7 @@ public interface ChannelFutureListener extends EventListener {
|
||||
* A {@link ChannelFutureListener} that closes the {@link Channel} when the
|
||||
* operation ended up with a failure or cancellation rather than a success.
|
||||
*/
|
||||
static ChannelFutureListener CLOSE_ON_FAILURE = new ChannelFutureListener() {
|
||||
ChannelFutureListener CLOSE_ON_FAILURE = new ChannelFutureListener() {
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
if (!future.isSuccess()) {
|
||||
future.getChannel().close();
|
||||
|
@ -51,7 +51,7 @@ package org.jboss.netty.channel;
|
||||
* public void login(String username, password) {
|
||||
* {@link Channels}.write(
|
||||
* <b>this.ctx</b>,
|
||||
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()</b>),
|
||||
* {@link Channels}.succeededFuture(<b>this.ctx.getChannel()</b>),
|
||||
* new LoginMessage(username, password));
|
||||
* }
|
||||
* ...
|
||||
|
@ -39,12 +39,12 @@ public @interface ChannelPipelineCoverage {
|
||||
/**
|
||||
* {@code "all"}
|
||||
*/
|
||||
public static final String ALL = "all";
|
||||
String ALL = "all";
|
||||
|
||||
/**
|
||||
* {@code "one"}
|
||||
*/
|
||||
public static final String ONE = "one";
|
||||
String ONE = "one";
|
||||
|
||||
/**
|
||||
* The value of this annotation
|
||||
|
@ -47,7 +47,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
|
||||
* {@link ChannelHandlerContext#sendDownstream(ChannelEvent)} by yourself.
|
||||
* @apiviz.landmark
|
||||
*/
|
||||
public class Channels {
|
||||
public final class Channels {
|
||||
|
||||
// pipeline factory methods
|
||||
|
||||
|
@ -88,7 +88,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
||||
return state.get() == ST_CONNECTED;
|
||||
}
|
||||
|
||||
final void setBound() throws ClosedChannelException {
|
||||
void setBound() throws ClosedChannelException {
|
||||
if (!state.compareAndSet(ST_OPEN, ST_BOUND)) {
|
||||
switch (state.get()) {
|
||||
case ST_CLOSED:
|
||||
@ -99,7 +99,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
||||
}
|
||||
}
|
||||
|
||||
final void setConnected() {
|
||||
void setConnected() {
|
||||
if (state.get() != ST_CLOSED) {
|
||||
state.set(ST_CONNECTED);
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
Channel channel = e.getChannel();
|
||||
if (channel instanceof DefaultLocalServerChannel) {
|
||||
handleServerChannel(e);
|
||||
}
|
||||
else if (channel instanceof DefaultLocalChannel) {
|
||||
} else if (channel instanceof DefaultLocalChannel) {
|
||||
handleAcceptedChannel(e);
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +125,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
public ChannelFuture write(Object message, SocketAddress remoteAddress) {
|
||||
if (remoteAddress == null || remoteAddress.equals(getRemoteAddress())) {
|
||||
return super.write(message, null);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return getUnsupportedOperationFuture();
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ final class HttpTunnelingClientSocketPipelineSink extends AbstractChannelSink {
|
||||
break;
|
||||
}
|
||||
} else if (e instanceof MessageEvent) {
|
||||
channel.writeReal(((ChannelBuffer) ((MessageEvent) e).getMessage()), future);
|
||||
channel.writeReal((ChannelBuffer) ((MessageEvent) e).getMessage(), future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import org.jboss.netty.util.internal.SystemPropertyUtil;
|
||||
* Provides information which is specific to a NIO service provider
|
||||
* implementation.
|
||||
*/
|
||||
class NioProviderMetadata {
|
||||
final class NioProviderMetadata {
|
||||
static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(NioProviderMetadata.class);
|
||||
|
||||
|
@ -40,4 +40,8 @@ final class SelectorUtil {
|
||||
" raised by a Selector - JDK bug?", e);
|
||||
}
|
||||
}
|
||||
|
||||
private SelectorUtil() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ final class SocketReceiveBufferPool {
|
||||
super();
|
||||
}
|
||||
|
||||
final ByteBuffer acquire(int size) {
|
||||
ByteBuffer acquire(int size) {
|
||||
final SoftReference<ByteBuffer>[] pool = this.pool;
|
||||
for (int i = 0; i < POOL_SIZE; i ++) {
|
||||
SoftReference<ByteBuffer> ref = pool[i];
|
||||
@ -60,7 +60,7 @@ final class SocketReceiveBufferPool {
|
||||
return buf;
|
||||
}
|
||||
|
||||
final void release(ByteBuffer buffer) {
|
||||
void release(ByteBuffer buffer) {
|
||||
final SoftReference<ByteBuffer>[] pool = this.pool;
|
||||
for (int i = 0; i < POOL_SIZE; i ++) {
|
||||
SoftReference<ByteBuffer> ref = pool[i];
|
||||
@ -87,7 +87,7 @@ final class SocketReceiveBufferPool {
|
||||
}
|
||||
}
|
||||
|
||||
private static final int normalizeCapacity(int capacity) {
|
||||
private static int normalizeCapacity(int capacity) {
|
||||
// Normalize to multiple of 1024
|
||||
int q = capacity >>> 10;
|
||||
int r = capacity & 1023;
|
||||
|
@ -36,14 +36,14 @@ final class SocketSendBufferPool {
|
||||
private static final int ALIGN_SHIFT = 4;
|
||||
private static final int ALIGN_MASK = 15;
|
||||
|
||||
PreallocationRef poolHead = null;
|
||||
PreallocationRef poolHead;
|
||||
Preallocation current = new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
||||
|
||||
SocketSendBufferPool() {
|
||||
super();
|
||||
}
|
||||
|
||||
final SendBuffer acquire(Object message) {
|
||||
SendBuffer acquire(Object message) {
|
||||
if (message instanceof ChannelBuffer) {
|
||||
return acquire((ChannelBuffer) message);
|
||||
} else if (message instanceof FileRegion) {
|
||||
@ -54,14 +54,14 @@ final class SocketSendBufferPool {
|
||||
"unsupported message type: " + message.getClass());
|
||||
}
|
||||
|
||||
private final SendBuffer acquire(FileRegion src) {
|
||||
private SendBuffer acquire(FileRegion src) {
|
||||
if (src.getCount() == 0) {
|
||||
return EMPTY_BUFFER;
|
||||
}
|
||||
return new FileSendBuffer(src);
|
||||
}
|
||||
|
||||
private final SendBuffer acquire(ChannelBuffer src) {
|
||||
private SendBuffer acquire(ChannelBuffer src) {
|
||||
final int size = src.readableBytes();
|
||||
if (size == 0) {
|
||||
return EMPTY_BUFFER;
|
||||
@ -107,7 +107,7 @@ final class SocketSendBufferPool {
|
||||
return dst;
|
||||
}
|
||||
|
||||
private final Preallocation getPreallocation() {
|
||||
private Preallocation getPreallocation() {
|
||||
Preallocation current = this.current;
|
||||
if (current.refCnt == 0) {
|
||||
current.buffer.clear();
|
||||
@ -117,7 +117,7 @@ final class SocketSendBufferPool {
|
||||
return getPreallocation0();
|
||||
}
|
||||
|
||||
private final Preallocation getPreallocation0() {
|
||||
private Preallocation getPreallocation0() {
|
||||
PreallocationRef ref = poolHead;
|
||||
if (ref != null) {
|
||||
do {
|
||||
@ -136,7 +136,7 @@ final class SocketSendBufferPool {
|
||||
return new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
||||
}
|
||||
|
||||
private static final int align(int pos) {
|
||||
private static int align(int pos) {
|
||||
int q = pos >>> ALIGN_SHIFT;
|
||||
int r = pos & ALIGN_MASK;
|
||||
if (r != 0) {
|
||||
@ -301,23 +301,23 @@ final class SocketSendBufferPool {
|
||||
super();
|
||||
}
|
||||
|
||||
public final boolean finished() {
|
||||
public boolean finished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final long writtenBytes() {
|
||||
public long writtenBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long totalBytes() {
|
||||
public long totalBytes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long transferTo(WritableByteChannel ch) throws IOException {
|
||||
public long transferTo(WritableByteChannel ch) throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||
public long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,22 @@ public class DiscardClient {
|
||||
firstMessageSize = 256;
|
||||
}
|
||||
|
||||
new DiscardClient(host, port, firstMessageSize).run();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final int firstMessageSize;
|
||||
|
||||
public DiscardClient(String host, int port, int firstMessageSize) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.firstMessageSize = firstMessageSize;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the client.
|
||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||
new NioClientSocketChannelFactory(
|
||||
|
@ -38,7 +38,7 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
DiscardClientHandler.class.getName());
|
||||
|
||||
private long transferredBytes = 0;
|
||||
private long transferredBytes;
|
||||
private final byte[] content;
|
||||
|
||||
public DiscardClientHandler(int messageSize) {
|
||||
@ -84,7 +84,7 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
@Override
|
||||
public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) {
|
||||
transferredBytes =+e.getWrittenAmount();
|
||||
transferredBytes += e.getWrittenAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
public class DiscardServer {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DiscardServer().run();
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the server.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||
new NioServerSocketChannelFactory(
|
||||
|
@ -34,7 +34,7 @@ public class DiscardServerHandler extends SimpleChannelUpstreamHandler {
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
DiscardServerHandler.class.getName());
|
||||
|
||||
private long transferredBytes = 0;
|
||||
private long transferredBytes;
|
||||
|
||||
public long getTransferredBytes() {
|
||||
return transferredBytes;
|
||||
@ -53,7 +53,7 @@ public class DiscardServerHandler extends SimpleChannelUpstreamHandler {
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
|
||||
// Discard received data silently by doing nothing.
|
||||
transferredBytes += (((ChannelBuffer) e.getMessage()).readableBytes());
|
||||
transferredBytes += ((ChannelBuffer) e.getMessage()).readableBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +52,20 @@ public class EchoClient {
|
||||
firstMessageSize = 256;
|
||||
}
|
||||
|
||||
new EchoClient(host, port, firstMessageSize).run();
|
||||
}
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final int firstMessageSize;
|
||||
|
||||
public EchoClient(String host, int port, int firstMessageSize) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.firstMessageSize = firstMessageSize;
|
||||
}
|
||||
|
||||
public void run(String host, int port, final int firstMessageSize) {
|
||||
// Configure the client.
|
||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||
new NioClientSocketChannelFactory(
|
||||
|
@ -30,6 +30,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
public class EchoServer {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new EchoServer().run();
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the server.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||
new NioServerSocketChannelFactory(
|
||||
|
@ -46,6 +46,20 @@ public class FactorialClient {
|
||||
throw new IllegalArgumentException("count must be a positive integer.");
|
||||
}
|
||||
|
||||
new FactorialClient(host, port, count).run();
|
||||
}
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final int count;
|
||||
|
||||
public FactorialClient(String host, int port, int count) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the client.
|
||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||
new NioClientSocketChannelFactory(
|
||||
|
@ -45,7 +45,7 @@ public class FactorialClientHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Stateful properties
|
||||
private int i = 1;
|
||||
private int receivedMessages = 0;
|
||||
private int receivedMessages;
|
||||
private final int count;
|
||||
final BlockingQueue<BigInteger> answer = new LinkedBlockingQueue<BigInteger>();
|
||||
|
||||
|
@ -28,6 +28,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
public class FactorialServer {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new FactorialServer().run();
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Configure the server.
|
||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||
new NioServerSocketChannelFactory(
|
||||
|
@ -50,7 +50,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandler.class);
|
||||
|
||||
private WebSocketServerHandshaker handshaker = null;
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||
|
@ -37,13 +37,7 @@ import org.jboss.netty.handler.codec.http.websocketx.WebSocketVersion;
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConsoleHandler ch = new ConsoleHandler();
|
||||
ch.setLevel(Level.FINE);
|
||||
Logger.getLogger("").addHandler(ch);
|
||||
Logger.getLogger("").setLevel(Level.FINE);
|
||||
|
||||
runClient();
|
||||
System.exit(0);
|
||||
new App().runClient();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,7 +45,7 @@ public class App {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void runClient() throws Exception {
|
||||
public void runClient() throws Exception {
|
||||
|
||||
MyCallbackHandler callbackHandler = new MyCallbackHandler();
|
||||
WebSocketClientFactory factory = new WebSocketClientFactory();
|
||||
@ -95,7 +89,7 @@ public class App {
|
||||
* Our web socket callback handler for this app
|
||||
*/
|
||||
public static class MyCallbackHandler implements WebSocketCallback {
|
||||
public boolean connected = false;
|
||||
public boolean connected;
|
||||
public ArrayList<String> messagesReceived = new ArrayList<String>();
|
||||
|
||||
public MyCallbackHandler() {
|
||||
|
@ -53,9 +53,9 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler impleme
|
||||
private URI url;
|
||||
private final WebSocketCallback callback;
|
||||
private Channel channel;
|
||||
private WebSocketClientHandshaker handshaker = null;
|
||||
private WebSocketClientHandshaker handshaker;
|
||||
private final WebSocketVersion version;
|
||||
private Map<String, String> customHeaders = null;
|
||||
private Map<String, String> customHeaders;
|
||||
|
||||
public WebSocketClientHandler(ClientBootstrap bootstrap, URI url, WebSocketVersion version,
|
||||
WebSocketCallback callback, Map<String, String> customHeaders) {
|
||||
|
@ -24,14 +24,12 @@ package org.jboss.netty.example.http.websocketx.client;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Copied from https://github.com/cgbystrom/netty-tools
|
||||
*
|
||||
* A WebSocket related exception
|
||||
*
|
||||
* Copied from https://github.com/cgbystrom/netty-tools
|
||||
*/
|
||||
public class WebSocketException extends IOException {
|
||||
|
||||
/**
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public WebSocketException(String s) {
|
||||
|
@ -52,7 +52,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
private static final String WEBSOCKET_PATH = "/websocket";
|
||||
|
||||
private WebSocketServerHandshaker handshaker = null;
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
/**
|
||||
* Generates the demo HTML page which is served at http://localhost:8080/
|
||||
*/
|
||||
public class WebSocketServerIndexPage {
|
||||
public final class WebSocketServerIndexPage {
|
||||
|
||||
private static final String NEWLINE = "\r\n";
|
||||
|
||||
@ -89,4 +89,8 @@ public class WebSocketServerIndexPage {
|
||||
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
||||
CharsetUtil.US_ASCII);
|
||||
}
|
||||
|
||||
private WebSocketServerIndexPage() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
private static final String WEBSOCKET_PATH = "/websocket";
|
||||
|
||||
private WebSocketServerHandshaker handshaker = null;
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
/**
|
||||
* Generates the demo HTML page which is served at http://localhost:8080/
|
||||
*/
|
||||
public class WebSocketSslServerIndexPage {
|
||||
public final class WebSocketSslServerIndexPage {
|
||||
|
||||
private static final String NEWLINE = "\r\n";
|
||||
|
||||
@ -89,4 +89,8 @@ public class WebSocketSslServerIndexPage {
|
||||
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
||||
CharsetUtil.US_ASCII);
|
||||
}
|
||||
|
||||
private WebSocketSslServerIndexPage() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
/**
|
||||
* Creates a {@link SSLContext} for just server certificates.
|
||||
*/
|
||||
public class WebSocketSslServerSslContext {
|
||||
public final class WebSocketSslServerSslContext {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketSslServerSslContext.class);
|
||||
private static final String PROTOCOL = "TLS";
|
||||
@ -98,5 +98,4 @@ public class WebSocketSslServerSslContext {
|
||||
public SSLContext getServerContext() {
|
||||
return _serverContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,19 +18,16 @@
|
||||
* <p>This package contains an example web socket web server with server SSL.
|
||||
* <p>To run this example, follow the steps below:
|
||||
* <dl>
|
||||
* <dt>Step 1. Generate Your Key</dt>
|
||||
* <dt>Step 1. Generate Your Key
|
||||
* <dd>
|
||||
* <code>keytool -genkey -keystore mySrvKeystore -keyalg RSA</code>.
|
||||
* Make sure that you set the key password to be the same the key file password.
|
||||
* </dd>
|
||||
* <dt>Step 2. Specify your key store file and password as system properties</dt>
|
||||
* <dt>Step 2. Specify your key store file and password as system properties
|
||||
* <dd>
|
||||
* <code>-Dkeystore.file.path=<path to mySrvKeystore> -Dkeystore.file.password=<password></code>
|
||||
* </dd>
|
||||
* <dt>Step 3. Run WebSocketSslServer as a Java application</dt>
|
||||
* <dt>Step 3. Run WebSocketSslServer as a Java application
|
||||
* <dd>
|
||||
* Once started, you can test the web server against your browser by navigating to https://localhost:8081/
|
||||
* </dd>
|
||||
* </dl>
|
||||
* <p>To find out more about setting up key stores, refer to this
|
||||
* <a href="http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html">giude</a>.
|
||||
|
@ -42,6 +42,20 @@ public class HexDumpProxy {
|
||||
String remoteHost = args[1];
|
||||
int remotePort = Integer.parseInt(args[2]);
|
||||
|
||||
new HexDumpProxy(localPort, remoteHost, remotePort).run();
|
||||
}
|
||||
|
||||
private final int localPort;
|
||||
private final String remoteHost;
|
||||
private final int remotePort;
|
||||
|
||||
public HexDumpProxy(int localPort, String remoteHost, int remotePort) {
|
||||
this.localPort = localPort;
|
||||
this.remoteHost = remoteHost;
|
||||
this.remotePort = remotePort;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
System.err.println(
|
||||
"Proxying *:" + localPort + " to " +
|
||||
remoteHost + ':' + remotePort + " ...");
|
||||
|
@ -30,7 +30,7 @@ import java.io.InputStream;
|
||||
* -keystore cert.jks
|
||||
* </pre>
|
||||
*/
|
||||
public class SecureChatKeyStore {
|
||||
public final class SecureChatKeyStore {
|
||||
private static final short[] DATA = new short[] {
|
||||
0xfe, 0xed, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
|
||||
|
@ -49,7 +49,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
||||
* to validate the client certificate.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class SecureChatSslContextFactory {
|
||||
public final class SecureChatSslContextFactory {
|
||||
|
||||
private static final String PROTOCOL = "TLS";
|
||||
private static final SSLContext SERVER_CONTEXT;
|
||||
@ -99,4 +99,8 @@ public class SecureChatSslContextFactory {
|
||||
public static SSLContext getClientContext() {
|
||||
return CLIENT_CONTEXT;
|
||||
}
|
||||
|
||||
private SecureChatSslContextFactory() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
* @apiviz.landmark
|
||||
* @apiviz.uses org.jboss.netty.handler.codec.base64.Base64Dialect
|
||||
*/
|
||||
public class Base64 {
|
||||
public final class Base64 {
|
||||
|
||||
/** Maximum line length (76) of Base64 output. */
|
||||
private static final int MAX_LINE_LENGTH = 76;
|
||||
@ -47,21 +47,21 @@ public class Base64 {
|
||||
|
||||
private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
||||
|
||||
private static final byte[] alphabet(Base64Dialect dialect) {
|
||||
private static byte[] alphabet(Base64Dialect dialect) {
|
||||
if (dialect == null) {
|
||||
throw new NullPointerException("dialect");
|
||||
}
|
||||
return dialect.alphabet;
|
||||
}
|
||||
|
||||
private static final byte[] decodabet(Base64Dialect dialect) {
|
||||
private static byte[] decodabet(Base64Dialect dialect) {
|
||||
if (dialect == null) {
|
||||
throw new NullPointerException("dialect");
|
||||
}
|
||||
return dialect.decodabet;
|
||||
}
|
||||
|
||||
private static final boolean breakLines(Base64Dialect dialect) {
|
||||
private static boolean breakLines(Base64Dialect dialect) {
|
||||
if (dialect == null) {
|
||||
throw new NullPointerException("dialect");
|
||||
}
|
||||
@ -301,9 +301,9 @@ public class Base64 {
|
||||
sbiDecode = DECODABET[sbiCrop];
|
||||
|
||||
if (sbiDecode >= WHITE_SPACE_ENC) { // White space, Equals sign or better
|
||||
if (sbiDecode >= EQUALS_SIGN_ENC) {
|
||||
if (sbiDecode >= EQUALS_SIGN_ENC) { // Equals sign or better?
|
||||
b4[b4Posn ++] = sbiCrop;
|
||||
if (b4Posn > 3) {
|
||||
if (b4Posn > 3) { // Quartet built?
|
||||
outBuffPosn += decode4to3(
|
||||
b4, 0, dest, outBuffPosn, dialect);
|
||||
b4Posn = 0;
|
||||
@ -312,10 +312,9 @@ public class Base64 {
|
||||
if (sbiCrop == EQUALS_SIGN) {
|
||||
break;
|
||||
}
|
||||
} // end if: quartet built
|
||||
} // end if: equals sign or better
|
||||
} // end if: white space, equals sign or better
|
||||
else {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"bad Base64 input character at " + i + ": " +
|
||||
src.getUnsignedByte(i) + " (decimal)");
|
||||
@ -331,18 +330,16 @@ public class Base64 {
|
||||
|
||||
byte[] DECODABET = decodabet(dialect);
|
||||
|
||||
// Example: Dk==
|
||||
if (src[srcOffset + 2] == EQUALS_SIGN) {
|
||||
// Example: Dk==
|
||||
int outBuff =
|
||||
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
||||
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12;
|
||||
|
||||
dest.setByte(destOffset, (byte) (outBuff >>> 16));
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else if (src[srcOffset + 3] == EQUALS_SIGN) {
|
||||
// Example: DkL=
|
||||
else if (src[srcOffset + 3] == EQUALS_SIGN) {
|
||||
int outBuff =
|
||||
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
||||
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12 |
|
||||
@ -351,10 +348,8 @@ public class Base64 {
|
||||
dest.setByte(destOffset , (byte) (outBuff >>> 16));
|
||||
dest.setByte(destOffset + 1, (byte) (outBuff >>> 8));
|
||||
return 2;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Example: DkLE
|
||||
else {
|
||||
int outBuff;
|
||||
try {
|
||||
outBuff =
|
||||
|
@ -21,7 +21,7 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
|
||||
/**
|
||||
*/
|
||||
class EmbeddedChannelFactory implements ChannelFactory {
|
||||
final class EmbeddedChannelFactory implements ChannelFactory {
|
||||
|
||||
static final ChannelFactory INSTANCE = new EmbeddedChannelFactory();
|
||||
|
||||
|
@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
||||
/**
|
||||
* A set of commonly used delimiters for {@link DelimiterBasedFrameDecoder}.
|
||||
*/
|
||||
public class Delimiters {
|
||||
public final class Delimiters {
|
||||
|
||||
/**
|
||||
* Returns a {@code NUL (0x00)} delimiter, which could be used for
|
||||
|
@ -145,8 +145,8 @@ import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
|
||||
* header from the frame. If you don't want to strip the prepended header, you
|
||||
* could specify <tt>0</tt> for <tt>initialBytesToSkip</tt>.
|
||||
* <pre>
|
||||
* lengthFieldOffset</b> = 1 (= the length of HDR1)
|
||||
* lengthFieldLength</b> = 2
|
||||
* lengthFieldOffset = 1 (= the length of HDR1)
|
||||
* lengthFieldLength = 2
|
||||
* <b>lengthAdjustment</b> = <b>1</b> (= the length of HDR2)
|
||||
* <b>initialBytesToStrip</b> = <b>3</b> (= the length of HDR1 + LEN)
|
||||
*
|
||||
@ -403,14 +403,12 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
|
||||
this.tooLongFrameLength = 0;
|
||||
discardingTooLongFrame = false;
|
||||
if ((!failFast) ||
|
||||
(failFast && firstDetectionOfTooLongFrame))
|
||||
{
|
||||
(failFast && firstDetectionOfTooLongFrame)) {
|
||||
fail(ctx, tooLongFrameLength);
|
||||
}
|
||||
} else {
|
||||
// Keep discarding and notify handlers if necessary.
|
||||
if (failFast && firstDetectionOfTooLongFrame)
|
||||
{
|
||||
if (failFast && firstDetectionOfTooLongFrame) {
|
||||
fail(ctx, this.tooLongFrameLength);
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class CookieDecoder {
|
||||
|
||||
private final static Pattern PATTERN =
|
||||
private static final Pattern PATTERN =
|
||||
Pattern.compile("(?:\\s|[;,])*\\$*([^;=]+)(?:=(?:[\"']((?:\\\\.|[^\"])*)[\"']|([^;,]*)))?(\\s*(?:[;,]+\\s*|$))");
|
||||
|
||||
private final static String COMMA = ",";
|
||||
private static final String COMMA = ",";
|
||||
|
||||
private final boolean lenient;
|
||||
|
||||
|
@ -204,8 +204,9 @@ public class CookieEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
if(sb.length() > 0)
|
||||
if (sb.length() > 0) {
|
||||
sb.setLength(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public interface HttpChunk {
|
||||
/**
|
||||
* The 'end of content' marker in chunked encoding.
|
||||
*/
|
||||
static HttpChunkTrailer LAST_CHUNK = new HttpChunkTrailer() {
|
||||
HttpChunkTrailer LAST_CHUNK = new HttpChunkTrailer() {
|
||||
public ChannelBuffer getContent() {
|
||||
return ChannelBuffers.EMPTY_BUFFER;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
/**
|
||||
*/
|
||||
class HttpCodecUtil {
|
||||
final class HttpCodecUtil {
|
||||
//space ' '
|
||||
static final byte SP = 32;
|
||||
|
||||
|
@ -568,11 +568,9 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (lineLength >= maxLineLength) {
|
||||
// TODO: Respond with Bad Request and discard the traffic
|
||||
// or close the connection.
|
||||
|
@ -190,8 +190,7 @@ public class QueryStringDecoder {
|
||||
int pathEndPos = uri.indexOf('?');
|
||||
if (pathEndPos < 0) {
|
||||
path = uri;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return path = uri.substring(0, pathEndPos);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
*/
|
||||
public class ContinuationWebSocketFrame extends WebSocketFrame {
|
||||
|
||||
private String aggregatedText = null;
|
||||
private String aggregatedText;
|
||||
|
||||
/**
|
||||
* Creates a new empty continuation frame.
|
||||
|
@ -42,7 +42,7 @@ final class UTF8Output {
|
||||
12, 12, 12, 12, 12, 12, 12, 12 };
|
||||
|
||||
private int state = UTF8_ACCEPT;
|
||||
private int codep = 0;
|
||||
private int codep;
|
||||
|
||||
private final StringBuilder stringBuilder;
|
||||
|
||||
@ -60,7 +60,7 @@ final class UTF8Output {
|
||||
public void write(int b) {
|
||||
byte type = TYPES[b & 0xFF];
|
||||
|
||||
codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & (b);
|
||||
codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & b;
|
||||
|
||||
state = STATES[state + type];
|
||||
|
||||
|
@ -64,20 +64,20 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
private static final byte OPCODE_PING = 0x9;
|
||||
private static final byte OPCODE_PONG = 0xA;
|
||||
|
||||
private UTF8Output fragmentedFramesText = null;
|
||||
private int fragmentedFramesCount = 0;
|
||||
private UTF8Output fragmentedFramesText;
|
||||
private int fragmentedFramesCount;
|
||||
|
||||
private boolean frameFinalFlag;
|
||||
private int frameRsv;
|
||||
private int frameOpcode;
|
||||
private long framePayloadLength;
|
||||
private ChannelBuffer framePayload = null;
|
||||
private int framePayloadBytesRead = 0;
|
||||
private ChannelBuffer framePayload;
|
||||
private int framePayloadBytesRead;
|
||||
private ChannelBuffer maskingKey;
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean maskedPayload = false;
|
||||
private boolean receivedClosingHandshake = false;
|
||||
private boolean allowExtensions;
|
||||
private boolean maskedPayload;
|
||||
private boolean receivedClosingHandshake;
|
||||
|
||||
public enum State {
|
||||
FRAME_START, MASKING_KEY, PAYLOAD, CORRUPT
|
||||
@ -118,7 +118,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
byte b = buffer.readByte();
|
||||
frameFinalFlag = (b & 0x80) != 0;
|
||||
frameRsv = (b & 0x70) >> 4;
|
||||
frameOpcode = (b & 0x0F);
|
||||
frameOpcode = b & 0x0F;
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Decoding WebSocket Frame opCode=" + frameOpcode);
|
||||
@ -127,7 +127,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
// MASK, PAYLOAD LEN 1
|
||||
b = buffer.readByte();
|
||||
boolean frameMasked = (b & 0x80) != 0;
|
||||
int framePayloadLen1 = (b & 0x7F);
|
||||
int framePayloadLen1 = b & 0x7F;
|
||||
|
||||
if (frameRsv != 0 && !this.allowExtensions) {
|
||||
protocolViolation(channel, "RSV != 0 and no extension negotiated, RSV:" + frameRsv);
|
||||
|
@ -66,7 +66,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
||||
private static final byte OPCODE_PING = 0x9;
|
||||
private static final byte OPCODE_PONG = 0xA;
|
||||
|
||||
private boolean maskPayload = false;
|
||||
private boolean maskPayload;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -116,7 +116,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
||||
|
||||
int b0 = 0;
|
||||
if (frame.isFinalFragment()) {
|
||||
b0 |= (1 << 7);
|
||||
b0 |= 1 << 7;
|
||||
}
|
||||
b0 |= (frame.getRsv() % 8) << 4;
|
||||
b0 |= opcode % 128;
|
||||
@ -138,13 +138,13 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
||||
} else if (length <= 0xFFFF) {
|
||||
header = ChannelBuffers.buffer(4 + maskLength);
|
||||
header.writeByte(b0);
|
||||
header.writeByte(this.maskPayload ? (0xFE) : 126);
|
||||
header.writeByte(this.maskPayload ? 0xFE : 126);
|
||||
header.writeByte((length >>> 8) & 0xFF);
|
||||
header.writeByte((length) & 0xFF);
|
||||
header.writeByte(length & 0xFF);
|
||||
} else {
|
||||
header = ChannelBuffers.buffer(10 + maskLength);
|
||||
header.writeByte(b0);
|
||||
header.writeByte(this.maskPayload ? (0xFF) : 127);
|
||||
header.writeByte(this.maskPayload ? 0xFF : 127);
|
||||
header.writeLong(length);
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ public abstract class WebSocketClientHandshaker {
|
||||
|
||||
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
||||
|
||||
private boolean openingHandshakeCompleted = false;
|
||||
private boolean openingHandshakeCompleted;
|
||||
|
||||
private String subProtocolRequest = null;
|
||||
private String subProtocolRequest;
|
||||
|
||||
private String subProtocolResponse = null;
|
||||
private String subProtocolResponse;
|
||||
|
||||
protected Map<String, String> customHeaders = null;
|
||||
protected Map<String, String> customHeaders;
|
||||
|
||||
/**
|
||||
* Base constructor
|
||||
|
@ -45,7 +45,7 @@ import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
*/
|
||||
public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
|
||||
private byte[] expectedChallengeResponseBytes = null;
|
||||
private byte[] expectedChallengeResponseBytes;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location and version to initiate
|
||||
|
@ -46,11 +46,11 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
|
||||
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
private String expectedChallengeResponseString = null;
|
||||
private String expectedChallengeResponseString;
|
||||
|
||||
private static final String protocol = null;
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean allowExtensions;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location and version to initiate
|
||||
|
@ -46,11 +46,11 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
|
||||
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
private String expectedChallengeResponseString = null;
|
||||
private String expectedChallengeResponseString;
|
||||
|
||||
private static final String protocol = null;
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean allowExtensions;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location and version to initiate
|
||||
|
@ -31,7 +31,7 @@ public abstract class WebSocketFrame {
|
||||
/**
|
||||
* RSV1, RSV2, RSV3 used for extensions
|
||||
*/
|
||||
private int rsv = 0;
|
||||
private int rsv;
|
||||
|
||||
/**
|
||||
* Contents of this frame
|
||||
|
@ -31,7 +31,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
|
||||
private String subProtocols;
|
||||
|
||||
private String[] subProtocolsArray = null;
|
||||
private String[] subProtocolsArray;
|
||||
|
||||
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
||||
|
||||
public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean allowExtensions;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location
|
||||
|
@ -49,7 +49,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
||||
|
||||
public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean allowExtensions;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location
|
||||
|
@ -32,7 +32,7 @@ public class WebSocketServerHandshakerFactory {
|
||||
|
||||
private final String subProtocols;
|
||||
|
||||
private boolean allowExtensions = false;
|
||||
private boolean allowExtensions;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location
|
||||
|
@ -19,7 +19,7 @@ import java.lang.ref.Reference;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ClassResolvers {
|
||||
public final class ClassResolvers {
|
||||
|
||||
/**
|
||||
* cache disabled
|
||||
@ -86,4 +86,8 @@ public class ClassResolvers {
|
||||
|
||||
return ClassResolvers.class.getClassLoader();
|
||||
}
|
||||
|
||||
private ClassResolvers() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
|
||||
tasks.add(command);
|
||||
|
||||
|
||||
if (isRunning.get() == false) {
|
||||
if (!isRunning.get()) {
|
||||
doUnorderedExecute(this);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class SslHandler extends FrameDecoder
|
||||
private final Queue<MessageEvent> pendingEncryptedWrites = QueueFactory.createQueue(MessageEvent.class);
|
||||
private final NonReentrantLock pendingEncryptedWritesLock = new NonReentrantLock();
|
||||
|
||||
private volatile boolean issueHandshake = false;
|
||||
private volatile boolean issueHandshake;
|
||||
|
||||
private static final ChannelFutureListener HANDSHAKE_LISTENER = new ChannelFutureListener() {
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||
* A utility class that provides various common operations and constants
|
||||
* related with {@link Charset} and its relevant classes.
|
||||
*/
|
||||
public class CharsetUtil {
|
||||
public final class CharsetUtil {
|
||||
|
||||
/**
|
||||
* 16-bit UTF (UCS Transformation Format) whose byte order is identified by
|
||||
|
@ -32,7 +32,7 @@ import org.jboss.netty.util.internal.SystemPropertyUtil;
|
||||
* {@link ChannelPipeline} or {@link ChannelSink} are retained as it is to help
|
||||
* debugging Netty.
|
||||
*/
|
||||
public class DebugUtil {
|
||||
public final class DebugUtil {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if Netty debug mode is enabled.
|
||||
|
@ -19,7 +19,7 @@ package org.jboss.netty.util;
|
||||
* A utility class that provides the convenient shutdown of
|
||||
* {@link ExternalResourceReleasable}s.
|
||||
*/
|
||||
public class ExternalResourceUtil {
|
||||
public final class ExternalResourceUtil {
|
||||
|
||||
/**
|
||||
* Releases the specified {@link ExternalResourceReleasable}s.
|
||||
|
@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
*/
|
||||
public class UnsafeDetectUtil {
|
||||
public final class UnsafeDetectUtil {
|
||||
|
||||
private static final String UNSAFE = "sun.misc.Unsafe";
|
||||
private static final boolean UNSAFE_FOUND = isUnsafeFound(AtomicInteger.class.getClassLoader());
|
||||
|
@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
|
||||
/**
|
||||
*/
|
||||
class AtomicFieldUpdaterUtil {
|
||||
final class AtomicFieldUpdaterUtil {
|
||||
|
||||
private static final boolean AVAILABLE;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
/**
|
||||
* The maximum capacity, used if a higher value is implicitly specified by
|
||||
* either of the constructors with arguments. MUST be a power of two
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
*/
|
||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||
|
||||
@ -131,7 +131,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
* @param hash the hash code for the key
|
||||
* @return the segment
|
||||
*/
|
||||
final Segment<K, V> segmentFor(int hash) {
|
||||
Segment<K, V> segmentFor(int hash) {
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
@ -166,21 +166,21 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final K key() {
|
||||
K key() {
|
||||
return (K) key;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final V value() {
|
||||
V value() {
|
||||
return (V) value;
|
||||
}
|
||||
|
||||
final void setValue(V value) {
|
||||
void setValue(V value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
return new HashEntry[i];
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
||||
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
@ -916,8 +916,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
@ -960,8 +958,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if the specified key is null
|
||||
*/
|
||||
public boolean remove(Object key, Object value) {
|
||||
@ -973,8 +969,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
*/
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
@ -986,8 +980,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
|
@ -65,7 +65,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
/**
|
||||
* The maximum capacity, used if a higher value is implicitly specified by
|
||||
* either of the constructors with arguments. MUST be a power of two
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
*/
|
||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||
|
||||
@ -131,7 +131,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
* @param hash the hash code for the key
|
||||
* @return the segment
|
||||
*/
|
||||
final Segment<K, V> segmentFor(int hash) {
|
||||
Segment<K, V> segmentFor(int hash) {
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
@ -166,21 +166,21 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final K key() {
|
||||
K key() {
|
||||
return (K) key;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final V value() {
|
||||
V value() {
|
||||
return (V) value;
|
||||
}
|
||||
|
||||
final void setValue(V value) {
|
||||
void setValue(V value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
return new HashEntry[i];
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
||||
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
@ -916,8 +916,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
@ -960,8 +958,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if the specified key is null
|
||||
*/
|
||||
public boolean remove(Object key, Object value) {
|
||||
@ -973,8 +969,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
*/
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
@ -986,8 +980,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
|
@ -72,7 +72,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
/**
|
||||
* The maximum capacity, used if a higher value is implicitly specified by
|
||||
* either of the constructors with arguments. MUST be a power of two
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
*/
|
||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||
|
||||
@ -138,7 +138,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
* @param hash the hash code for the key
|
||||
* @return the segment
|
||||
*/
|
||||
final Segment<K, V> segmentFor(int hash) {
|
||||
Segment<K, V> segmentFor(int hash) {
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
@ -160,11 +160,11 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public final int keyHash() {
|
||||
public int keyHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public final Object keyRef() {
|
||||
public Object keyRef() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -197,16 +197,16 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final K key() {
|
||||
K key() {
|
||||
return ((WeakReference<K>) keyRef).get();
|
||||
}
|
||||
|
||||
final V value() {
|
||||
V value() {
|
||||
return dereferenceValue(valueRef);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final V dereferenceValue(Object value) {
|
||||
V dereferenceValue(Object value) {
|
||||
if (value instanceof WeakKeyReference) {
|
||||
return ((Reference<V>) value).get();
|
||||
}
|
||||
@ -214,12 +214,12 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
return (V) value;
|
||||
}
|
||||
|
||||
final void setValue(V value) {
|
||||
void setValue(V value) {
|
||||
this.valueRef = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
return new HashEntry[i];
|
||||
}
|
||||
}
|
||||
@ -311,7 +311,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
||||
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
@ -611,7 +611,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final void removeStale() {
|
||||
void removeStale() {
|
||||
WeakKeyReference ref;
|
||||
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
||||
remove(ref.keyRef(), ref.keyHash(), null, true);
|
||||
@ -979,8 +979,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
@ -1023,8 +1021,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if the specified key is null
|
||||
*/
|
||||
public boolean remove(Object key, Object value) {
|
||||
@ -1036,8 +1032,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
*/
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
@ -1049,8 +1043,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
|
@ -72,7 +72,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
/**
|
||||
* The maximum capacity, used if a higher value is implicitly specified by
|
||||
* either of the constructors with arguments. MUST be a power of two
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||
*/
|
||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||
|
||||
@ -138,7 +138,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
* @param hash the hash code for the key
|
||||
* @return the segment
|
||||
*/
|
||||
final Segment<K, V> segmentFor(int hash) {
|
||||
Segment<K, V> segmentFor(int hash) {
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
@ -160,11 +160,11 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public final int keyHash() {
|
||||
public int keyHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public final Object keyRef() {
|
||||
public Object keyRef() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -197,16 +197,16 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final K key() {
|
||||
K key() {
|
||||
return ((WeakReference<K>) keyRef).get();
|
||||
}
|
||||
|
||||
final V value() {
|
||||
V value() {
|
||||
return dereferenceValue(valueRef);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final V dereferenceValue(Object value) {
|
||||
V dereferenceValue(Object value) {
|
||||
if (value instanceof WeakKeyReference) {
|
||||
return ((Reference<V>) value).get();
|
||||
}
|
||||
@ -214,12 +214,12 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
return (V) value;
|
||||
}
|
||||
|
||||
final void setValue(V value) {
|
||||
void setValue(V value) {
|
||||
this.valueRef = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||
return new HashEntry[i];
|
||||
}
|
||||
}
|
||||
@ -311,7 +311,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
||||
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
@ -611,7 +611,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final void removeStale() {
|
||||
void removeStale() {
|
||||
WeakKeyReference ref;
|
||||
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
||||
remove(ref.keyRef(), ref.keyHash(), null, true);
|
||||
@ -979,8 +979,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
@ -1023,8 +1021,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if the specified key is null
|
||||
*/
|
||||
public boolean remove(Object key, Object value) {
|
||||
@ -1036,8 +1032,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
*/
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
@ -1049,8 +1043,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return the previous value associated with the specified key, or
|
||||
* <tt>null</tt> if there was no mapping for the key
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||
* Conversion utility class to parse a property represented as a string or
|
||||
* an object.
|
||||
*/
|
||||
public class ConversionUtil {
|
||||
public final class ConversionUtil {
|
||||
|
||||
/**
|
||||
* Converts the specified object into an integer.
|
||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* their termination. An {@link Executor} which is not an {@link ExecutorService}
|
||||
* will be ignored silently.
|
||||
*/
|
||||
public class ExecutorUtil {
|
||||
public final class ExecutorUtil {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if the specified {@code executor}
|
||||
|
@ -59,7 +59,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean tryAcquire(int acquires) {
|
||||
protected boolean tryAcquire(int acquires) {
|
||||
if (compareAndSetState(0, 1)) {
|
||||
owner = Thread.currentThread();
|
||||
return true;
|
||||
@ -68,7 +68,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean tryRelease(int releases) {
|
||||
protected boolean tryRelease(int releases) {
|
||||
if (Thread.currentThread() != owner) {
|
||||
throw new IllegalMonitorStateException();
|
||||
}
|
||||
@ -78,7 +78,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isHeldExclusively() {
|
||||
protected boolean isHeldExclusively() {
|
||||
return getState() != 0 && owner == Thread.currentThread();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import org.jboss.netty.util.UnsafeDetectUtil;
|
||||
|
||||
|
||||
*/
|
||||
public class QueueFactory {
|
||||
public final class QueueFactory {
|
||||
|
||||
private static final boolean useUnsafe = UnsafeDetectUtil.isUnsafeFound(QueueFactory.class.getClassLoader());
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.jboss.netty.util.ThreadRenamingRunnable;
|
||||
* {@link StackTraceElement}s. Please note that the stack trace simplification
|
||||
* is disabled if {@linkplain DebugUtil debug mode} is turned on.
|
||||
*/
|
||||
public class StackTraceSimplifier {
|
||||
public final class StackTraceSimplifier {
|
||||
|
||||
private static final boolean SIMPLIFY_STACK_TRACE = !DebugUtil.isDebugEnabled();
|
||||
private static final Pattern EXCLUDED_STACK_TRACE =
|
||||
@ -80,4 +80,8 @@ public class StackTraceSimplifier {
|
||||
e.setStackTrace(
|
||||
simpleTrace.toArray(new StackTraceElement[simpleTrace.size()]));
|
||||
}
|
||||
|
||||
private StackTraceSimplifier() {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.util.Formatter;
|
||||
/**
|
||||
* String utility class.
|
||||
*/
|
||||
public class StringUtil {
|
||||
public final class StringUtil {
|
||||
|
||||
private StringUtil() {
|
||||
// Unused.
|
||||
|
@ -20,7 +20,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* Accesses the system property swallowing a {@link SecurityException}.
|
||||
*/
|
||||
public class SystemPropertyUtil {
|
||||
public final class SystemPropertyUtil {
|
||||
|
||||
/**
|
||||
* Returns the value of the Java system property with the specified
|
||||
|
@ -48,9 +48,9 @@ import java.util.Random;
|
||||
*/
|
||||
final class ThreadLocalRandom extends Random {
|
||||
// same constants as Random, but must be redeclared because private
|
||||
private final static long multiplier = 0x5DEECE66DL;
|
||||
private final static long addend = 0xBL;
|
||||
private final static long mask = (1L << 48) - 1;
|
||||
private static final long multiplier = 0x5DEECE66DL;
|
||||
private static final long addend = 0xBL;
|
||||
private static final long mask = (1L << 48) - 1;
|
||||
|
||||
/**
|
||||
* The random seed. We can't use super.seed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user