Fix various checkstyle violations

Backported from master
This commit is contained in:
Trustin Lee 2012-01-11 20:17:47 +09:00
parent 53fede511c
commit e2109b236b
107 changed files with 481 additions and 439 deletions

View File

@ -215,7 +215,7 @@ public class Bootstrap implements ExternalResourceReleasable {
}
ChannelPipeline pipeline = pipeline();
for(Map.Entry<String, ChannelHandler> e: pipelineMap.entrySet()) {
for (Map.Entry<String, ChannelHandler> e: pipelineMap.entrySet()) {
pipeline.addLast(e.getKey(), e.getValue());
}
@ -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() {

View File

@ -56,60 +56,60 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
}
public short getShort(int index) {
return (short) (array[index] << 8 | array[index+1] & 0xFF);
return (short) (array[index] << 8 | array[index + 1] & 0xFF);
}
public int getUnsignedMedium(int index) {
return (array[index] & 0xff) << 16 |
(array[index+1] & 0xff) << 8 |
(array[index+2] & 0xff) << 0;
return (array[index] & 0xff) << 16 |
(array[index + 1] & 0xff) << 8 |
(array[index + 2] & 0xff) << 0;
}
public int getInt(int index) {
return (array[index] & 0xff) << 24 |
(array[index+1] & 0xff) << 16 |
(array[index+2] & 0xff) << 8 |
(array[index+3] & 0xff) << 0;
return (array[index] & 0xff) << 24 |
(array[index + 1] & 0xff) << 16 |
(array[index + 2] & 0xff) << 8 |
(array[index + 3] & 0xff) << 0;
}
public long getLong(int index) {
return ((long) array[index] & 0xff) << 56 |
((long) array[index+1] & 0xff) << 48 |
((long) array[index+2] & 0xff) << 40 |
((long) array[index+3] & 0xff) << 32 |
((long) array[index+4] & 0xff) << 24 |
((long) array[index+5] & 0xff) << 16 |
((long) array[index+6] & 0xff) << 8 |
((long) array[index+7] & 0xff) << 0;
return ((long) array[index] & 0xff) << 56 |
((long) array[index + 1] & 0xff) << 48 |
((long) array[index + 2] & 0xff) << 40 |
((long) array[index + 3] & 0xff) << 32 |
((long) array[index + 4] & 0xff) << 24 |
((long) array[index + 5] & 0xff) << 16 |
((long) array[index + 6] & 0xff) << 8 |
((long) array[index + 7] & 0xff) << 0;
}
public void setShort(int index, int value) {
array[index ] = (byte) (value >>> 8);
array[index+1] = (byte) (value >>> 0);
array[index] = (byte) (value >>> 8);
array[index + 1] = (byte) (value >>> 0);
}
public void setMedium(int index, int value) {
array[index ] = (byte) (value >>> 16);
array[index+1] = (byte) (value >>> 8);
array[index+2] = (byte) (value >>> 0);
array[index] = (byte) (value >>> 16);
array[index + 1] = (byte) (value >>> 8);
array[index + 2] = (byte) (value >>> 0);
}
public void setInt(int index, int value) {
array[index ] = (byte) (value >>> 24);
array[index+1] = (byte) (value >>> 16);
array[index+2] = (byte) (value >>> 8);
array[index+3] = (byte) (value >>> 0);
array[index] = (byte) (value >>> 24);
array[index + 1] = (byte) (value >>> 16);
array[index + 2] = (byte) (value >>> 8);
array[index + 3] = (byte) (value >>> 0);
}
public void setLong(int index, long value) {
array[index ] = (byte) (value >>> 56);
array[index+1] = (byte) (value >>> 48);
array[index+2] = (byte) (value >>> 40);
array[index+3] = (byte) (value >>> 32);
array[index+4] = (byte) (value >>> 24);
array[index+5] = (byte) (value >>> 16);
array[index+6] = (byte) (value >>> 8);
array[index+7] = (byte) (value >>> 0);
array[index] = (byte) (value >>> 56);
array[index + 1] = (byte) (value >>> 48);
array[index + 2] = (byte) (value >>> 40);
array[index + 3] = (byte) (value >>> 32);
array[index + 4] = (byte) (value >>> 24);
array[index + 5] = (byte) (value >>> 16);
array[index + 6] = (byte) (value >>> 8);
array[index + 7] = (byte) (value >>> 0);
}
public ChannelBuffer duplicate() {

View File

@ -97,9 +97,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
}
public int getUnsignedMedium(int index) {
return (getByte(index) & 0xff) << 16 |
(getByte(index+1) & 0xff) << 8 |
(getByte(index+2) & 0xff) << 0;
return (getByte(index) & 0xff) << 16 |
(getByte(index + 1) & 0xff) << 8 |
(getByte(index + 2) & 0xff) << 0;
}
public int getInt(int index) {
@ -154,9 +154,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
}
public void setMedium(int index, int value) {
setByte(index, (byte) (value >>> 16));
setByte(index+1, (byte) (value >>> 8));
setByte(index+2, (byte) (value >>> 0));
setByte(index, (byte) (value >>> 16));
setByte(index + 1, (byte) (value >>> 8));
setByte(index + 2, (byte) (value >>> 0));
}
public void setInt(int index, int value) {

View File

@ -47,7 +47,7 @@ import java.nio.charset.UnsupportedCharsetException;
*
* <pre>
* {@link ChannelBuffer} buffer = ...;
* for (int i = 0; i &lt; buffer.capacity(); i ++</strong>) {
* for (int i = 0; i &lt; buffer.capacity(); i ++) {
* byte b = buffer.getByte(i);
* System.out.println((char) b);
* }

View File

@ -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';

View File

@ -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.
@ -308,7 +308,7 @@ public class ChannelBuffers {
return EMPTY_BUFFER;
}
if (buffer.hasArray()) {
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(),buffer.remaining());
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
} else {
return new ByteBufferBackedChannelBuffer(buffer);
}

View File

@ -326,8 +326,8 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
setShort(index, (short) (value >> 8));
setByte(index + 2, (byte) value);
} else {
setShort(index , (short) value);
setByte (index + 2, (byte) (value >>> 16));
setShort(index , (short) value);
setByte(index + 2, (byte) (value >>> 16));
}
}

View File

@ -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;
/**

View File

@ -56,60 +56,60 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
}
public short getShort(int index) {
return (short) (array[index] & 0xFF | array[index+1] << 8);
return (short) (array[index] & 0xFF | array[index + 1] << 8);
}
public int getUnsignedMedium(int index) {
return (array[index ] & 0xff) << 0 |
(array[index+1] & 0xff) << 8 |
(array[index+2] & 0xff) << 16;
return (array[index] & 0xff) << 0 |
(array[index + 1] & 0xff) << 8 |
(array[index + 2] & 0xff) << 16;
}
public int getInt(int index) {
return (array[index ] & 0xff) << 0 |
(array[index+1] & 0xff) << 8 |
(array[index+2] & 0xff) << 16 |
(array[index+3] & 0xff) << 24;
return (array[index] & 0xff) << 0 |
(array[index + 1] & 0xff) << 8 |
(array[index + 2] & 0xff) << 16 |
(array[index + 3] & 0xff) << 24;
}
public long getLong(int index) {
return ((long) array[index] & 0xff) << 0 |
((long) array[index+1] & 0xff) << 8 |
((long) array[index+2] & 0xff) << 16 |
((long) array[index+3] & 0xff) << 24 |
((long) array[index+4] & 0xff) << 32 |
((long) array[index+5] & 0xff) << 40 |
((long) array[index+6] & 0xff) << 48 |
((long) array[index+7] & 0xff) << 56;
return ((long) array[index] & 0xff) << 0 |
((long) array[index + 1] & 0xff) << 8 |
((long) array[index + 2] & 0xff) << 16 |
((long) array[index + 3] & 0xff) << 24 |
((long) array[index + 4] & 0xff) << 32 |
((long) array[index + 5] & 0xff) << 40 |
((long) array[index + 6] & 0xff) << 48 |
((long) array[index + 7] & 0xff) << 56;
}
public void setShort(int index, int value) {
array[index ] = (byte) (value >>> 0);
array[index+1] = (byte) (value >>> 8);
array[index] = (byte) (value >>> 0);
array[index + 1] = (byte) (value >>> 8);
}
public void setMedium(int index, int value) {
array[index ] = (byte) (value >>> 0);
array[index+1] = (byte) (value >>> 8);
array[index+2] = (byte) (value >>> 16);
array[index] = (byte) (value >>> 0);
array[index + 1] = (byte) (value >>> 8);
array[index + 2] = (byte) (value >>> 16);
}
public void setInt(int index, int value) {
array[index ] = (byte) (value >>> 0);
array[index+1] = (byte) (value >>> 8);
array[index+2] = (byte) (value >>> 16);
array[index+3] = (byte) (value >>> 24);
array[index] = (byte) (value >>> 0);
array[index + 1] = (byte) (value >>> 8);
array[index + 2] = (byte) (value >>> 16);
array[index + 3] = (byte) (value >>> 24);
}
public void setLong(int index, long value) {
array[index ] = (byte) (value >>> 0);
array[index+1] = (byte) (value >>> 8);
array[index+2] = (byte) (value >>> 16);
array[index+3] = (byte) (value >>> 24);
array[index+4] = (byte) (value >>> 32);
array[index+5] = (byte) (value >>> 40);
array[index+6] = (byte) (value >>> 48);
array[index+7] = (byte) (value >>> 56);
array[index] = (byte) (value >>> 0);
array[index + 1] = (byte) (value >>> 8);
array[index + 2] = (byte) (value >>> 16);
array[index + 3] = (byte) (value >>> 24);
array[index + 4] = (byte) (value >>> 32);
array[index + 5] = (byte) (value >>> 40);
array[index + 6] = (byte) (value >>> 48);
array[index + 7] = (byte) (value >>> 56);
}
public ChannelBuffer duplicate() {

View File

@ -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.

View File

@ -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>

View File

@ -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();

View File

@ -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));
* }
* ...

View File

@ -219,7 +219,7 @@ public interface ChannelPipeline {
* @throws NullPointerException
* if the specified name or handler is {@code null}
*/
void addFirst (String name, ChannelHandler handler);
void addFirst(String name, ChannelHandler handler);
/**
* Appends a {@link ChannelHandler} at the last position of this pipeline.
@ -232,7 +232,7 @@ public interface ChannelPipeline {
* @throws NullPointerException
* if the specified name or handler is {@code null}
*/
void addLast (String name, ChannelHandler handler);
void addLast(String name, ChannelHandler handler);
/**
* Inserts a {@link ChannelHandler} before an existing handler of this
@ -266,7 +266,7 @@ public interface ChannelPipeline {
* @throws NullPointerException
* if the specified baseName, name, or handler is {@code null}
*/
void addAfter (String baseName, String name, ChannelHandler handler);
void addAfter(String baseName, String name, ChannelHandler handler);
/**
* Removes the specified {@link ChannelHandler} from this pipeline.

View File

@ -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

View File

@ -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

View File

@ -80,4 +80,4 @@ public interface FileRegion extends ExternalResourceReleasable {
* byte of the region transferred.
*/
long transferTo(WritableByteChannel target, long position) throws IOException;
}
}

View File

@ -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);
}
@ -157,7 +157,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
void flushWriteBuffer() {
DefaultLocalChannel pairedChannel = this.pairedChannel;
if (pairedChannel != null) {
if (pairedChannel.isConnected()){
if (pairedChannel.isConnected()) {
// Channel is open and connected and channelConnected event has
// been fired.
if (!delivering.get()) {
@ -165,7 +165,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
try {
for (;;) {
MessageEvent e = writeBuffer.poll();
if(e == null) {
if (e == null) {
break;
}
@ -192,7 +192,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
for (;;) {
MessageEvent e = writeBuffer.poll();
if(e == null) {
if (e == null) {
break;
}

View File

@ -103,7 +103,7 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
public int compareTo(LocalAddress o) {
if (ephemeral) {
if (o.ephemeral) {
if (this == o){
if (this == o) {
return 0;
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -211,17 +211,17 @@ public final class HttpTunnelingSocketChannelConfig implements SocketChannelConf
return true;
}
if (key.equals("serverName")){
if (key.equals("serverName")) {
setServerName(String.valueOf(value));
} else if (key.equals("serverPath")){
} else if (key.equals("serverPath")) {
setServerPath(String.valueOf(value));
} else if (key.equals("sslContext")) {
setSslContext((SSLContext) value);
} else if (key.equals("enabledSslCipherSuites")){
} else if (key.equals("enabledSslCipherSuites")) {
setEnabledSslCipherSuites(ConversionUtil.toStringArray(value));
} else if (key.equals("enabledSslProtocols")){
} else if (key.equals("enabledSslProtocols")) {
setEnabledSslProtocols(ConversionUtil.toStringArray(value));
} else if (key.equals("enableSslSessionCreation")){
} else if (key.equals("enableSslSessionCreation")) {
setEnableSslSessionCreation(ConversionUtil.toBoolean(value));
} else {
return false;

View File

@ -29,7 +29,7 @@ import org.jboss.netty.util.internal.QueueFactory;
*/
abstract class AbstractWriteRequestQueue implements BlockingQueue<MessageEvent>{
abstract class AbstractWriteRequestQueue implements BlockingQueue<MessageEvent> {
protected final BlockingQueue<MessageEvent> queue;

View File

@ -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);

View File

@ -40,4 +40,8 @@ final class SelectorUtil {
" raised by a Selector - JDK bug?", e);
}
}
private SelectorUtil() {
// Unused
}
}

View File

@ -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];
@ -72,7 +72,7 @@ final class SocketReceiveBufferPool {
// pool is full - replace one
final int capacity = buffer.capacity();
for (int i = 0; i< POOL_SIZE; i ++) {
for (int i = 0; i < POOL_SIZE; i ++) {
SoftReference<ByteBuffer> ref = pool[i];
ByteBuffer pooled = ref.get();
if (pooled == null) {
@ -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;
@ -96,4 +96,4 @@ final class SocketReceiveBufferPool {
}
return q << 10;
}
}
}

View File

@ -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) {
@ -287,7 +287,7 @@ final class SocketSendBufferPool {
public void release() {
if (file instanceof DefaultFileRegion) {
if (((DefaultFileRegion)file).releaseAfterTransfer()) {
if (((DefaultFileRegion) file).releaseAfterTransfer()) {
// Make sure the FileRegion resource are released otherwise it may cause a FD leak or something similar
file.releaseExternalResources();
}
@ -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;
}

View File

@ -137,7 +137,7 @@ class OioWorker implements Runnable {
}
} finally {
if (fr instanceof DefaultFileRegion) {
if (((DefaultFileRegion)fr).releaseAfterTransfer()) {
if (((DefaultFileRegion) fr).releaseAfterTransfer()) {
fr.releaseExternalResources();
}
}

View File

@ -48,7 +48,23 @@ public class DiscardClient {
} else {
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(

View File

@ -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

View File

@ -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(

View File

@ -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

View File

@ -51,7 +51,21 @@ public class EchoClient {
} else {
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(

View File

@ -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(

View File

@ -45,7 +45,21 @@ public class FactorialClient {
if (count <= 0) {
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(

View File

@ -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>();

View File

@ -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(

View File

@ -140,7 +140,7 @@ public class HttpRequestHandler extends SimpleChannelUpstreamHandler {
if (cookieString != null) {
CookieDecoder cookieDecoder = new CookieDecoder();
Set<Cookie> cookies = cookieDecoder.decode(cookieString);
if(!cookies.isEmpty()) {
if (!cookies.isEmpty()) {
// Reset the cookies if necessary.
CookieEncoder cookieEncoder = new CookieEncoder(true);
for (Cookie cookie : cookies) {

View File

@ -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 {
@ -130,4 +130,4 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
private String getWebSocketLocation(HttpRequest req) {
return "ws://" + req.getHeader(HttpHeaders.Names.HOST);
}
}
}

View File

@ -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() {

View File

@ -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) {
@ -124,4 +124,4 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler impleme
this.url = url;
}
}
}

View File

@ -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) {
@ -41,4 +39,4 @@ public class WebSocketException extends IOException {
public WebSocketException(String s, Throwable throwable) {
super(s, throwable);
}
}
}

View File

@ -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 {
@ -143,4 +143,4 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
private String getWebSocketLocation(HttpRequest req) {
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
}
}
}

View File

@ -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
}
}

View File

@ -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 {
@ -143,4 +143,4 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
private String getWebSocketLocation(HttpRequest req) {
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
}
}
}

View File

@ -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
}
}

View File

@ -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;
}
}

View File

@ -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>
* <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>
* <dd>
* <code>-Dkeystore.file.path=&lt;path to mySrvKeystore&gt; -Dkeystore.file.password=&lt;password&gt;</code>
* </dd>
* <dt>Step 3. Run WebSocketSslServer as a Java application</dt>
* <dd>
* Once started, you can test the web server against your browser by navigating to https://localhost:8081/
* </dd>
* <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.
* <dt>Step 2. Specify your key store file and password as system properties
* <dd>
* <code>-Dkeystore.file.path=&lt;path to mySrvKeystore&gt; -Dkeystore.file.password=&lt;password&gt;</code>
* <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/
* </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>.

View File

@ -65,7 +65,7 @@ public class LocalExampleMultthreaded {
// Read commands from array
String[] commands = { "First", "Second", "Third", "quit" };
for (int j = 0; j < 5 ; j++) {
System.err.println("Start "+j);
System.err.println("Start " + j);
ChannelFuture channelFuture = cb.connect(socketAddress);
channelFuture.awaitUninterruptibly();
if (! channelFuture.isSuccess()) {
@ -86,7 +86,7 @@ public class LocalExampleMultthreaded {
channelFuture.getChannel().close();
// Wait until the connection is closed or the connection attempt fails.
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
System.err.println("End "+j);
System.err.println("End " + j);
}
// Release all resources

View File

@ -70,7 +70,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory {
Channels.close(e.getChannel());
return;
}
System.err.println("SERVER:"+msg);
System.err.println("SERVER:" + msg);
// Write back
Channels.write(e.getChannel(), msg);
}

View File

@ -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 + " ...");

View File

@ -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,

View File

@ -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
}
}

View File

@ -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");
}
@ -207,7 +207,7 @@ public class Base64 {
// We have to shift left 24 in order to flush out the 1's that appear
// when Java treats a value as negative that is cast from a byte to an int.
int inBuff =
(numSigBytes > 0? src.getByte(srcOffset ) << 24 >>> 8 : 0) |
(numSigBytes > 0? src.getByte(srcOffset) << 24 >>> 8 : 0) |
(numSigBytes > 1? src.getByte(srcOffset + 1) << 24 >>> 16 : 0) |
(numSigBytes > 2? src.getByte(srcOffset + 2) << 24 >>> 24 : 0);
@ -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;
}
// Example: DkL=
else if (src[srcOffset + 3] == EQUALS_SIGN) {
} else if (src[srcOffset + 3] == EQUALS_SIGN) {
// Example: DkL=
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;
}
// Example: DkLE
else {
} else {
// Example: DkLE
int outBuff;
try {
outBuff =

View File

@ -157,7 +157,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
ZlibUtil.fail(z, "initialization failure", resultCode);
} else {
resultCode = z.deflateSetDictionary(dictionary, dictionary.length);
if (resultCode != JZlib.Z_OK){
if (resultCode != JZlib.Z_OK) {
ZlibUtil.fail(z, "failed to set the dictionary", resultCode);
}
}

View File

@ -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();

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -145,7 +145,7 @@ public class CookieEncoder {
addQuoted(sb, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl());
}
if(!cookie.getPorts().isEmpty()) {
if (!cookie.getPorts().isEmpty()) {
sb.append(CookieHeaderNames.PORT);
sb.append((char) HttpCodecUtil.EQUALS);
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
@ -189,7 +189,7 @@ public class CookieEncoder {
}
if (cookie.getVersion() >= 1) {
if(!cookie.getPorts().isEmpty()) {
if (!cookie.getPorts().isEmpty()) {
sb.append('$');
sb.append(CookieHeaderNames.PORT);
sb.append((char) HttpCodecUtil.EQUALS);
@ -204,8 +204,9 @@ public class CookieEncoder {
}
}
if(sb.length() > 0)
sb.setLength(sb.length() - 1);
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
return sb.toString();
}

View File

@ -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;
}

View File

@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
/**
*/
class HttpCodecUtil {
final class HttpCodecUtil {
//space ' '
static final byte SP = 32;

View File

@ -46,7 +46,7 @@ public class HttpHeaders {
/**
* {@code "Accept-Encoding"}
*/
public static final String ACCEPT_ENCODING= "Accept-Encoding";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
/**
* {@code "Accept-Language"}
*/
@ -54,11 +54,11 @@ public class HttpHeaders {
/**
* {@code "Accept-Ranges"}
*/
public static final String ACCEPT_RANGES= "Accept-Ranges";
public static final String ACCEPT_RANGES = "Accept-Ranges";
/**
* {@code "Accept-Patch"}
*/
public static final String ACCEPT_PATCH= "Accept-Patch";
public static final String ACCEPT_PATCH = "Accept-Patch";
/**
* {@code "Age"}
*/
@ -90,7 +90,7 @@ public class HttpHeaders {
/**
* {@code "Content-Language"}
*/
public static final String CONTENT_LANGUAGE= "Content-Language";
public static final String CONTENT_LANGUAGE = "Content-Language";
/**
* {@code "Content-Length"}
*/
@ -114,7 +114,7 @@ public class HttpHeaders {
/**
* {@code "Content-Type"}
*/
public static final String CONTENT_TYPE= "Content-Type";
public static final String CONTENT_TYPE = "Content-Type";
/**
* {@code "Cookie"}
*/
@ -158,7 +158,7 @@ public class HttpHeaders {
/**
* {@code "If-Range"}
*/
public static final String IF_RANGE= "If-Range";
public static final String IF_RANGE = "If-Range";
/**
* {@code "If-Unmodified-Since"}
*/
@ -226,15 +226,15 @@ public class HttpHeaders {
/**
* {@code "Sec-WebSocket-Version"}
*/
public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
/**
* {@code "Sec-WebSocket-Key"}
*/
public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
/**
* {@code "Sec-WebSocket-Accept"}
*/
public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
/**
* {@code "Server"}
*/

View File

@ -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.

View File

@ -72,7 +72,7 @@ public class HttpRequestDecoder extends HttpMessageDecoder {
}
@Override
protected HttpMessage createMessage(String[] initialLine) throws Exception{
protected HttpMessage createMessage(String[] initialLine) throws Exception {
return new DefaultHttpRequest(
HttpVersion.valueOf(initialLine[2]), HttpMethod.valueOf(initialLine[0]), initialLine[1]);
}

View File

@ -143,7 +143,7 @@ public class QueryStringDecoder {
* Creates a new decoder that decodes the specified URI encoded in the
* specified charset.
*/
public QueryStringDecoder(URI uri, Charset charset){
public QueryStringDecoder(URI uri, Charset charset) {
this(uri, charset, DEFAULT_MAX_PARAMS);
}
@ -174,7 +174,7 @@ public class QueryStringDecoder {
* @deprecated Use {@link #QueryStringDecoder(URI, Charset)} instead.
*/
@Deprecated
public QueryStringDecoder(URI uri, String charset){
public QueryStringDecoder(URI uri, String charset) {
this(uri, Charset.forName(charset));
}
@ -190,8 +190,7 @@ public class QueryStringDecoder {
int pathEndPos = uri.indexOf('?');
if (pathEndPos < 0) {
path = uri;
}
else {
} else {
return path = uri.substring(0, pathEndPos);
}
}

View File

@ -114,7 +114,7 @@ public class QueryStringEncoder {
sb.append(encodeComponent(param.name, charset));
sb.append("=");
sb.append(encodeComponent(param.value, charset));
if(i != params.size() - 1) {
if (i != params.size() - 1) {
sb.append("&");
}
}

View File

@ -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.

View File

@ -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];

View File

@ -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);

View File

@ -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);
}
@ -170,4 +170,4 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
return msg;
}
}
}

View File

@ -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
@ -212,4 +212,4 @@ public abstract class WebSocketClientHandshaker {
protected int createRandomNumber(int min, int max) {
return (int) (Math.random() * max + min);
}
}
}

View File

@ -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
@ -243,4 +243,4 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
return key;
}
}
}

View File

@ -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

View File

@ -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
@ -188,4 +188,4 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
this.setOpenningHandshakeCompleted(true);
}
}
}

View File

@ -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

View File

@ -31,7 +31,7 @@ public abstract class WebSocketServerHandshaker {
private String subProtocols;
private String[] subProtocolsArray = null;
private String[] subProtocolsArray;
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
@ -180,4 +180,4 @@ public abstract class WebSocketServerHandshaker {
// No match found
return null;
}
}
}

View File

@ -195,4 +195,4 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
public void performClosingHandshake(Channel channel, CloseWebSocketFrame frame) {
channel.write(frame);
}
}
}

View File

@ -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
@ -163,4 +163,4 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
f.addListener(ChannelFutureListener.CLOSE);
}
}
}

View File

@ -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
@ -163,4 +163,4 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
f.addListener(ChannelFutureListener.CLOSE);
}
}
}

View File

@ -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

View File

@ -95,7 +95,7 @@ public class ProtobufDecoder extends OneToOneDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
if (buf.hasArray()) {
final int offset = buf.readerIndex();
if(extensionRegistry == null) {
if (extensionRegistry == null) {
return prototype.newBuilderForType().mergeFrom(
buf.array(), buf.arrayOffset() + offset, buf.readableBytes()).build();
} else {

View File

@ -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
}
}

View File

@ -295,7 +295,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
tasks.add(command);
if (isRunning.get() == false) {
if (!isRunning.get()) {
doUnorderedExecute(this);
}
}

View File

@ -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() {

View File

@ -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
@ -61,7 +61,7 @@ public class CharsetUtil {
public static final Charset US_ASCII = Charset.forName("US-ASCII");
private static final ThreadLocal<Map<Charset, CharsetEncoder>> encoders =
new ThreadLocal<Map<Charset,CharsetEncoder>>() {
new ThreadLocal<Map<Charset, CharsetEncoder>>() {
@Override
protected Map<Charset, CharsetEncoder> initialValue() {
return new IdentityHashMap<Charset, CharsetEncoder>();
@ -69,7 +69,7 @@ public class CharsetUtil {
};
private static final ThreadLocal<Map<Charset, CharsetDecoder>> decoders =
new ThreadLocal<Map<Charset,CharsetDecoder>>() {
new ThreadLocal<Map<Charset, CharsetDecoder>>() {
@Override
protected Map<Charset, CharsetDecoder> initialValue() {
return new IdentityHashMap<Charset, CharsetDecoder>();

View File

@ -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.

View File

@ -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.

View File

@ -543,7 +543,7 @@ public class HashedWheelTimer implements Timer {
}
if (isCancelled()) {
buf.append (", cancelled");
buf.append(", cancelled");
}
return buf.append(')').toString();

View File

@ -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());

View File

@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
/**
*/
class AtomicFieldUpdaterUtil {
final class AtomicFieldUpdaterUtil {
private static final boolean AVAILABLE;
@ -52,7 +52,7 @@ class AtomicFieldUpdaterUtil {
AVAILABLE = available;
}
static <T, V> AtomicReferenceFieldUpdater<T,V> newRefUpdater(Class<T> tclass, Class<V> vclass, String fieldName) {
static <T, V> AtomicReferenceFieldUpdater<T, V> newRefUpdater(Class<T> tclass, Class<V> vclass, String fieldName) {
if (AVAILABLE) {
return AtomicReferenceFieldUpdater.newUpdater(tclass, vclass, fieldName);
} else {

View File

@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
* @param <V> the type of mapped values
*/
public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
implements ConcurrentMap<K, V>{
implements ConcurrentMap<K, V> {
/**
* The default initial capacity for this table, used when not otherwise
@ -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.
* &lt;= 1&lt;&lt;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];
}
}
@ -262,11 +262,11 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
Segment(int initialCapacity, float lf) {
loadFactor = lf;
setTable(HashEntry.<K, V> newArray(initialCapacity));
setTable(HashEntry.<K, V>newArray(initialCapacity));
}
@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

View File

@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
* @param <V> the type of mapped values
*/
public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
implements ConcurrentMap<K, V>{
implements ConcurrentMap<K, V> {
/**
* The default initial capacity for this table, used when not otherwise
@ -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.
* &lt;= 1&lt;&lt;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];
}
}
@ -262,11 +262,11 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
Segment(int initialCapacity, float lf) {
loadFactor = lf;
setTable(HashEntry.<K, V> newArray(initialCapacity));
setTable(HashEntry.<K, V>newArray(initialCapacity));
}
@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

View File

@ -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.
* &lt;= 1&lt;&lt;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];
}
}
@ -307,11 +307,11 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
Segment(int initialCapacity, float lf) {
loadFactor = lf;
setTable(HashEntry.<K, V> newArray(initialCapacity));
setTable(HashEntry.<K, V>newArray(initialCapacity));
}
@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

View File

@ -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.
* &lt;= 1&lt;&lt;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];
}
}
@ -307,11 +307,11 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
Segment(int initialCapacity, float lf) {
loadFactor = lf;
setTable(HashEntry.<K, V> newArray(initialCapacity));
setTable(HashEntry.<K, V>newArray(initialCapacity));
}
@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

View File

@ -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.
@ -88,8 +88,8 @@ public class ConversionUtil {
}
private static final String[] INTEGERS = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10","11","12","13","14","15",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14", "15",
};
public static String toString(int value) {

View File

@ -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}

View File

@ -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();
}
}

View File

@ -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());

Some files were not shown because too many files have changed in this diff Show More