From b0a2b433796e542e851723a2841b5acb0607ba82 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 31 May 2012 11:52:10 -0700 Subject: [PATCH] Overall automated clean up --- .../netty/bootstrap/ClientBootstrap.java | 10 +- .../netty/buffer/AbstractChannelBuffer.java | 6 +- .../buffer/ChannelBufferInputStream.java | 4 +- .../netty/buffer/CompositeChannelBuffer.java | 10 +- .../netty/buffer/DynamicChannelBuffer.java | 4 +- .../java/org/jboss/netty/channel/Channel.java | 4 +- .../channel/ChannelDownstreamHandler.java | 2 +- .../jboss/netty/channel/ChannelPipeline.java | 2 +- .../org/jboss/netty/channel/ChannelSink.java | 2 +- .../org/jboss/netty/channel/Channels.java | 36 +- .../SimpleChannelDownstreamHandler.java | 2 +- .../channel/SimpleChannelUpstreamHandler.java | 6 +- .../socket/ChannelRunnableWrapper.java | 8 +- .../jboss/netty/channel/socket/Worker.java | 4 +- .../socket/nio/AbstractNioChannelSink.java | 2 +- .../channel/socket/nio/AbstractNioWorker.java | 82 +-- .../socket/nio/AbstractNioWorkerPool.java | 18 +- .../socket/nio/NioAcceptedSocketChannel.java | 4 +- .../nio/NioClientSocketChannelFactory.java | 8 +- .../channel/socket/nio/NioDatagramWorker.java | 32 +- .../socket/nio/NioDatagramWorkerPool.java | 2 +- .../nio/NioServerSocketChannelFactory.java | 8 +- .../netty/channel/socket/nio/NioWorker.java | 25 +- .../channel/socket/nio/NioWorkerPool.java | 2 +- .../socket/nio/ShareableWorkerPool.java | 4 +- .../socket/nio/SocketSendBufferPool.java | 10 +- .../netty/channel/socket/nio/WorkerPool.java | 4 +- .../socket/oio/AbstractOioChannelSink.java | 6 +- .../channel/socket/oio/AbstractOioWorker.java | 51 +- .../socket/oio/OioAcceptedSocketChannel.java | 5 +- .../oio/OioClientSocketChannelFactory.java | 6 +- .../socket/oio/OioDatagramChannel.java | 6 +- .../socket/oio/OioDatagramChannelFactory.java | 4 +- .../channel/socket/oio/OioDatagramWorker.java | 10 +- .../socket/oio/OioServerSocketChannel.java | 2 +- .../oio/OioServerSocketChannelFactory.java | 4 +- .../netty/channel/socket/oio/OioWorker.java | 12 +- .../netty/example/discard/DiscardServer.java | 2 +- .../jboss/netty/example/echo/EchoServer.java | 4 +- .../example/factorial/FactorialClient.java | 2 +- .../example/factorial/FactorialServer.java | 4 +- .../http/file/HttpStaticFileServer.java | 6 +- .../example/http/snoop/HttpSnoopClient.java | 2 +- .../example/http/snoop/HttpSnoopServer.java | 2 +- .../tunnel/HttpTunnelingClientExample.java | 2 +- .../example/http/upload/HttpUploadClient.java | 14 +- .../http/upload/HttpUploadClientHandler.java | 2 +- .../HttpUploadClientPipelineFactory.java | 2 +- .../example/http/upload/HttpUploadServer.java | 6 +- .../http/upload/HttpUploadServerHandler.java | 4 +- .../HttpUploadServerPipelineFactory.java | 2 +- .../websocketx/autobahn/AutobahnServer.java | 4 +- .../websocketx/autobahn/package-info.java | 30 +- .../websocketx/server/WebSocketServer.java | 14 +- .../http/websocketx/server/package-info.java | 8 +- .../sslserver/WebSocketSslServer.java | 12 +- .../WebSocketSslServerSslContext.java | 2 +- .../netty/example/local/LocalExample.java | 2 +- .../local/LocalExampleMultithreaded.java | 2 +- .../example/localtime/LocalTimeClient.java | 2 +- .../example/localtime/LocalTimeProtocol.java | 674 +++++++++--------- .../PortUnificationServer.java | 2 +- .../netty/example/proxy/HexDumpProxy.java | 2 +- .../example/securechat/SecureChatClient.java | 2 +- .../netty/example/telnet/TelnetClient.java | 2 +- .../netty/example/telnet/TelnetServer.java | 4 +- .../PrematureChannelClosureException.java | 18 +- .../handler/codec/base64/Base64Decoder.java | 2 +- .../handler/codec/base64/Base64Encoder.java | 2 +- .../codec/compression/ZlibEncoder.java | 2 +- .../frame/DelimiterBasedFrameDecoder.java | 2 +- .../codec/frame/FixedLengthFrameDecoder.java | 8 +- .../frame/LengthFieldBasedFrameDecoder.java | 6 +- .../codec/frame/LengthFieldPrepender.java | 2 +- .../handler/codec/http/HttpClientCodec.java | 14 +- .../multipart/DefaultHttpDataFactory.java | 10 +- .../codec/http/multipart/HttpData.java | 32 +- .../http/multipart/HttpPostBodyUtil.java | 16 +- .../http/websocketx/BinaryWebSocketFrame.java | 4 +- .../http/websocketx/CloseWebSocketFrame.java | 12 +- .../ContinuationWebSocketFrame.java | 10 +- .../http/websocketx/PingWebSocketFrame.java | 4 +- .../http/websocketx/PongWebSocketFrame.java | 4 +- .../http/websocketx/TextWebSocketFrame.java | 10 +- .../codec/http/websocketx/UTF8Exception.java | 16 +- .../codec/http/websocketx/UTF8Output.java | 16 +- .../websocketx/WebSocket00FrameDecoder.java | 8 +- .../websocketx/WebSocket00FrameEncoder.java | 4 +- .../websocketx/WebSocket08FrameEncoder.java | 2 +- .../websocketx/WebSocket13FrameDecoder.java | 4 +- .../websocketx/WebSocket13FrameEncoder.java | 2 +- .../websocketx/WebSocketClientHandshaker.java | 12 +- .../WebSocketClientHandshaker08.java | 32 +- .../WebSocketClientHandshaker13.java | 28 +- .../WebSocketClientHandshakerFactory.java | 8 +- .../websocketx/WebSocketServerHandshaker.java | 20 +- .../WebSocketServerHandshaker00.java | 26 +- .../WebSocketServerHandshaker08.java | 24 +- .../WebSocketServerHandshaker13.java | 28 +- .../WebSocketServerHandshakerFactory.java | 16 +- .../codec/http/websocketx/package-info.java | 4 +- .../marshalling/ChannelBufferByteInput.java | 4 +- .../marshalling/ChannelBufferByteOutput.java | 16 +- .../CompatibleMarshallingDecoder.java | 20 +- .../CompatibleMarshallingEncoder.java | 18 +- .../ContextBoundUnmarshallerProvider.java | 6 +- .../DefaultMarshallerProvider.java | 10 +- .../DefaultUnmarshallerProvider.java | 8 +- .../codec/marshalling/LimitingByteInput.java | 14 +- .../codec/marshalling/MarshallerProvider.java | 4 +- .../codec/marshalling/MarshallingDecoder.java | 12 +- .../codec/marshalling/MarshallingEncoder.java | 24 +- .../ThreadLocalMarshallerProvider.java | 10 +- .../ThreadLocalUnmarshallerProvider.java | 8 +- .../codec/protobuf/ProtobufEncoder.java | 2 +- .../ProtobufVarint32LengthFieldPrepender.java | 2 +- .../codec/replay/ReplayingDecoder.java | 38 +- .../replay/UnsafeDynamicChannelBuffer.java | 6 +- .../codec/rtsp/RtspMessageEncoder.java | 2 +- .../codec/serialization/ClassResolvers.java | 2 +- .../CompactObjectInputStream.java | 2 +- .../codec/serialization/ObjectDecoder.java | 8 +- .../ObjectDecoderInputStream.java | 2 +- .../codec/serialization/ObjectEncoder.java | 2 +- .../codec/serialization/ReferenceMap.java | 2 +- .../codec/spdy/DefaultSpdyHeaderBlock.java | 2 +- .../handler/codec/spdy/SpdyFrameDecoder.java | 14 +- .../handler/codec/spdy/SpdyFrameEncoder.java | 8 +- .../spdy/SpdyHeaderBlockZlibCompressor.java | 4 +- .../spdy/SpdyHeaderBlockZlibDecompressor.java | 4 +- .../netty/handler/codec/spdy/SpdySession.java | 18 +- .../codec/spdy/SpdySessionHandler.java | 2 +- .../handler/codec/string/StringDecoder.java | 2 +- .../handler/codec/string/StringEncoder.java | 2 +- .../handler/execution/ChainedExecutor.java | 12 +- .../execution/ChannelEventRunnable.java | 2 +- .../execution/ChannelEventRunnableFilter.java | 4 +- .../ChannelUpstreamEventRunnable.java | 2 +- .../handler/execution/ExecutionHandler.java | 8 +- .../OrderedDownstreamThreadPoolExecutor.java | 30 +- .../OrderedMemoryAwareThreadPoolExecutor.java | 8 +- .../jboss/netty/handler/ipfilter/CIDR.java | 4 +- .../ipfilter/IpFilteringHandlerImpl.java | 8 +- .../netty/handler/ipfilter/IpSubnet.java | 11 +- .../handler/queue/BufferedWriteHandler.java | 24 +- .../netty/handler/ssl/SslBufferPool.java | 14 +- .../handler/stream/ChunkedWriteHandler.java | 38 +- .../netty/handler/traffic/TrafficCounter.java | 8 +- .../jboss/netty/util/HashedWheelTimer.java | 6 +- .../netty/util/internal/DetectionUtil.java | 16 +- .../netty/util/internal/QueueFactory.java | 32 +- .../netty/util/internal/jzlib/Adler32.java | 2 +- .../netty/util/internal/jzlib/CRC32.java | 2 +- .../netty/util/internal/jzlib/JZlib.java | 2 +- .../jboss/netty/bootstrap/BootstrapTest.java | 2 +- .../buffer/AbstractChannelBufferTest.java | 2 +- .../netty/channel/local/LocalAddressTest.java | 14 +- .../netty/channel/local/LocalClientTest.java | 25 +- .../channel/socket/AbstractDatagramTest.java | 25 +- .../DefaultNioDatagramChannelConfigTest.java | 13 +- .../handler/codec/http/CookieEncoderTest.java | 12 +- .../codec/http/HttpClientCodecTest.java | 27 +- .../codec/http/QueryStringDecoderTest.java | 32 +- ...tractCompatibleMarshallingDecoderTest.java | 58 +- ...tractCompatibleMarshallingEncoderTest.java | 16 +- .../RiverMarshallingDecoderTest.java | 4 +- ...LocalCompatibleMarshallingEncoderTest.java | 2 +- ...iverThreadLocalMarshallingEncoderTest.java | 2 +- .../SerialMarshallingDecoderTest.java | 6 +- ...rialThreadLocalMarshallingEncoderTest.java | 2 +- .../codec/replay/ReplayingDecoderTest.java | 12 +- .../spdy/AbstractSocketSpdyEchoTest.java | 7 +- .../jboss/netty/handler/ssl/SslCloseTest.java | 10 +- .../java/org/jboss/netty/util/TestUtil.java | 10 +- 174 files changed, 1214 insertions(+), 1209 deletions(-) diff --git a/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java b/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java index 68c9d664e1..3ac9411cd5 100644 --- a/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java +++ b/src/main/java/org/jboss/netty/bootstrap/ClientBootstrap.java @@ -229,12 +229,12 @@ public class ClientBootstrap extends Bootstrap { // Connect. return ch.connect(remoteAddress); } - + /** * Attempts to bind a channel with the specified {@code localAddress}. later the channel can be connected * to a remoteAddress by calling {@link Channel#connect(SocketAddress)}.This method is useful where bind and connect - * need to be done in separate steps. - * + * need to be done in separate steps. + * * This can also be useful if you want to set an attachment to the {@link Channel} via * {@link Channel#setAttachment(Object)} so you can use it after the {@link #bind(SocketAddress)} was done. *
@@ -247,7 +247,7 @@ public class ClientBootstrap extends Bootstrap { * bootstrap.connect(new InetSocketAddress("192.168.0.30", 8080)); * *
- * + * * You can use it then in your handlers like this: * *
@@ -256,7 +256,7 @@ public class ClientBootstrap extends Bootstrap {
      *          Object dataObject = ctx.getChannel().getAttachment();
      *      }
      *  }
-     *  
+     *
      * 
* * @return a future object which notifies when this bind attempt diff --git a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java index 1355758361..4f27cd37fb 100644 --- a/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/AbstractChannelBuffer.java @@ -52,7 +52,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { public void writerIndex(int writerIndex) { if (writerIndex < readerIndex || writerIndex > capacity()) { - throw new IndexOutOfBoundsException("Invalid readerIndex: " + throw new IndexOutOfBoundsException("Invalid readerIndex: " + readerIndex + " - Maximum is " + writerIndex); } this.writerIndex = writerIndex; @@ -60,7 +60,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { public void setIndex(int readerIndex, int writerIndex) { if (readerIndex < 0 || readerIndex > writerIndex || writerIndex > capacity()) { - throw new IndexOutOfBoundsException("Invalid writerIndex: " + throw new IndexOutOfBoundsException("Invalid writerIndex: " + writerIndex + " - Maximum is " + readerIndex + " or " + capacity()); } this.readerIndex = readerIndex; @@ -116,7 +116,7 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer { public void ensureWritableBytes(int writableBytes) { if (writableBytes > writableBytes()) { - throw new IndexOutOfBoundsException("Writable bytes exceeded: Got " + throw new IndexOutOfBoundsException("Writable bytes exceeded: Got " + writableBytes + ", maximum is " + writableBytes()); } } diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java b/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java index c7420dfab5..e51f9f6092 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBufferInputStream.java @@ -189,7 +189,7 @@ public class ChannelBufferInputStream extends InputStream implements DataInput { lineBuf.setLength(lineBuf.length() - 1); } } - + return lineBuf.toString(); } @@ -227,7 +227,7 @@ public class ChannelBufferInputStream extends InputStream implements DataInput { throw new IndexOutOfBoundsException("fieldSize cannot be a negative number"); } if (fieldSize > available()) { - throw new EOFException("fieldSize is too long! Length is " + fieldSize + throw new EOFException("fieldSize is too long! Length is " + fieldSize + ", but maximum is " + available()); } } diff --git a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java index 2a55a0f381..cd605ceaca 100644 --- a/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/CompositeChannelBuffer.java @@ -216,7 +216,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { int componentId = componentId(index); if (index > capacity() - length || dstIndex > dst.length - length) { throw new IndexOutOfBoundsException("Too many bytes to read - Needs " - + (index + length) + ", maximum is " + capacity() + " or " + + (index + length) + ", maximum is " + capacity() + " or " + dst.length); } @@ -286,7 +286,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { if (DetectionUtil.javaVersion() >= 7) { return (int) out.write(toByteBuffers(index, length)); } - + // XXX Gathering write is not supported because of a known issue. // See http://bugs.sun.com/view_bug.do?bug_id=6210541 // This issue appeared in 2004 and is still unresolved!? @@ -297,7 +297,7 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { throws IOException { int componentId = componentId(index); if (index > capacity() - length) { - throw new IndexOutOfBoundsException("Too many bytes to be read - needs " + throw new IndexOutOfBoundsException("Too many bytes to be read - needs " + (index + length) + ", maximum of " + capacity()); } @@ -647,9 +647,9 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer { final int bytesToMove = capacity() - localReaderIndex; List list = decompose(localReaderIndex, bytesToMove); - + // If the list is empty we need to assign a new one because - // we get a List that is immutable. + // we get a List that is immutable. // // See https://github.com/netty/netty/issues/325 if (list.isEmpty()) { diff --git a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java index 420debf594..0a8f904587 100644 --- a/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java +++ b/src/main/java/org/jboss/netty/buffer/DynamicChannelBuffer.java @@ -73,8 +73,8 @@ public class DynamicChannelBuffer extends AbstractChannelBuffer { int minNewCapacity = writerIndex() + minWritableBytes; while (newCapacity < minNewCapacity) { newCapacity <<= 1; - - // Check if we exceeded the maximum size of 2gb if this is the case then + + // Check if we exceeded the maximum size of 2gb if this is the case then // newCapacity == 0 // // https://github.com/netty/netty/issues/258 diff --git a/src/main/java/org/jboss/netty/channel/Channel.java b/src/main/java/org/jboss/netty/channel/Channel.java index b127bebad4..72da5f9279 100644 --- a/src/main/java/org/jboss/netty/channel/Channel.java +++ b/src/main/java/org/jboss/netty/channel/Channel.java @@ -359,11 +359,11 @@ public interface Channel extends Comparable { * {@code interestOps} change request succeeds or fails */ ChannelFuture setReadable(boolean readable); - + /** * Retrieves an object which is {@link #setAttachment(Object) attached} to * this {@link Channel}. - * + * * @return {@code null} if no object was attached or {@code null} was * attached */ diff --git a/src/main/java/org/jboss/netty/channel/ChannelDownstreamHandler.java b/src/main/java/org/jboss/netty/channel/ChannelDownstreamHandler.java index ab431fe50f..44015f2c35 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelDownstreamHandler.java +++ b/src/main/java/org/jboss/netty/channel/ChannelDownstreamHandler.java @@ -57,7 +57,7 @@ package org.jboss.netty.channel; * You will also find various helper methods in {@link Channels} to be useful * to generate and send an artificial or manipulated event. *

- * Caution: + * Caution: *

* Use the *Later(..) methods of the {@link Channels} class if you want to send an upstream event from a {@link ChannelDownstreamHandler} otherwise you may run into threading issues. * diff --git a/src/main/java/org/jboss/netty/channel/ChannelPipeline.java b/src/main/java/org/jboss/netty/channel/ChannelPipeline.java index d24bc7692b..ee424eb072 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/ChannelPipeline.java @@ -460,7 +460,7 @@ public interface ChannelPipeline { * with this pipeline's {@link Channel}. */ ChannelFuture execute(Runnable task); - + /** * Returns the {@link Channel} that this pipeline is attached to. * diff --git a/src/main/java/org/jboss/netty/channel/ChannelSink.java b/src/main/java/org/jboss/netty/channel/ChannelSink.java index fe1f6ce5e0..fecd773d3d 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelSink.java +++ b/src/main/java/org/jboss/netty/channel/ChannelSink.java @@ -38,7 +38,7 @@ public interface ChannelSink { * one of its {@link ChannelHandler}s process a {@link ChannelEvent}. */ void exceptionCaught(ChannelPipeline pipeline, ChannelEvent e, ChannelPipelineException cause) throws Exception; - + /** * Execute the given {@link Runnable} later in the io-thread. * Some implementation may not support this and just execute it directly. diff --git a/src/main/java/org/jboss/netty/channel/Channels.java b/src/main/java/org/jboss/netty/channel/Channels.java index c5000b7c3b..bd8c1f771e 100644 --- a/src/main/java/org/jboss/netty/channel/Channels.java +++ b/src/main/java/org/jboss/netty/channel/Channels.java @@ -304,15 +304,15 @@ public final class Channels { */ public static ChannelFuture fireWriteCompleteLater(final Channel channel, final long amount) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireWriteComplete(channel, amount); } }); - + } - + /** * Sends a {@code "writeComplete"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -336,7 +336,7 @@ public final class Channels { public static void fireWriteComplete(ChannelHandlerContext ctx, long amount) { ctx.sendUpstream(new DefaultWriteCompletionEvent(ctx.getChannel(), amount)); } - + /** * Sends a {@code "channelInterestChanged"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -344,14 +344,14 @@ public final class Channels { */ public static ChannelFuture fireChannelInterestChangedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireChannelInterestChanged(channel); - + } }); } - + /** * Sends a {@code "channelInterestChanged"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -384,7 +384,7 @@ public final class Channels { */ public static ChannelFuture fireChannelDisconnectedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireChannelDisconnected(channel); } @@ -419,14 +419,14 @@ public final class Channels { */ public static ChannelFuture fireChannelUnboundLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireChannelUnbound(channel); } }); } - - + + /** * Sends a {@code "channelUnbound"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -449,8 +449,8 @@ public final class Channels { ctx.getChannel(), ChannelState.BOUND, null)); } - - + + /** * Sends a {@code "channelClosed"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -458,15 +458,15 @@ public final class Channels { */ public static ChannelFuture fireChannelClosedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireChannelClosed(channel); } }); - + } - - + + /** * Sends a {@code "channelClosed"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of @@ -502,7 +502,7 @@ public final class Channels { */ public static ChannelFuture fireExceptionCaughtLater(final Channel channel, final Throwable cause) { return channel.getPipeline().execute(new Runnable() { - + public void run() { fireExceptionCaught(channel, cause); } diff --git a/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java b/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java index 453987c35c..a1e590ca6f 100644 --- a/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java +++ b/src/main/java/org/jboss/netty/channel/SimpleChannelDownstreamHandler.java @@ -50,7 +50,7 @@ import java.net.SocketAddress; * } * } *

- * Caution: + * Caution: *

* Use the *Later(..) methods of the {@link Channels} class if you want to send an upstream event from a {@link ChannelDownstreamHandler} otherwise you may run into threading issues. * diff --git a/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java b/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java index df0942c2e7..6b86cfcb14 100644 --- a/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java +++ b/src/main/java/org/jboss/netty/channel/SimpleChannelUpstreamHandler.java @@ -146,7 +146,7 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler { /** * Invoked when a {@link Channel} is open, but not bound nor connected. *
- * + * * Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers! */ public void channelOpen( @@ -158,7 +158,7 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler { * Invoked when a {@link Channel} is open and bound to a local address, * but not connected. *
- * + * * Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers! */ public void channelBound( @@ -170,7 +170,7 @@ public class SimpleChannelUpstreamHandler implements ChannelUpstreamHandler { * Invoked when a {@link Channel} is open, bound to a local address, and * connected to a remote address. *
- * + * * Be aware that this event is fired from within the Boss-Thread so you should not execute any heavy operation in there as it will block the dispatching to other workers! */ public void channelConnected( diff --git a/src/main/java/org/jboss/netty/channel/socket/ChannelRunnableWrapper.java b/src/main/java/org/jboss/netty/channel/socket/ChannelRunnableWrapper.java index 323e18429e..caca3e469a 100644 --- a/src/main/java/org/jboss/netty/channel/socket/ChannelRunnableWrapper.java +++ b/src/main/java/org/jboss/netty/channel/socket/ChannelRunnableWrapper.java @@ -22,13 +22,13 @@ public class ChannelRunnableWrapper extends DefaultChannelFuture implements Runn private final Runnable task; private boolean started; - + public ChannelRunnableWrapper(Channel channel, Runnable task) { super(channel, true); this.task = task; } - + public void run() { synchronized (this) { if (!isCancelled()) { @@ -52,7 +52,7 @@ public class ChannelRunnableWrapper extends DefaultChannelFuture implements Runn } return super.cancel(); } - - + + } diff --git a/src/main/java/org/jboss/netty/channel/socket/Worker.java b/src/main/java/org/jboss/netty/channel/socket/Worker.java index 9e627a99cf..e619d99937 100644 --- a/src/main/java/org/jboss/netty/channel/socket/Worker.java +++ b/src/main/java/org/jboss/netty/channel/socket/Worker.java @@ -18,14 +18,14 @@ package org.jboss.netty.channel.socket; /** * A {@link Worker} is responsible to dispatch IO operations - * + * */ public interface Worker extends Runnable { /** * Execute the given {@link Runnable} in the IO-Thread. This may be now or * later once the IO-Thread do some other work. - * + * * @param task * the {@link Runnable} to execute */ diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioChannelSink.java b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioChannelSink.java index 7eadf5b294..894039ae73 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioChannelSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioChannelSink.java @@ -35,7 +35,7 @@ public abstract class AbstractNioChannelSink extends AbstractChannelSink { return wrapper; } return super.execute(pipeline, task); - + } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorker.java index 3b0176ad47..24c90ccab0 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorker.java @@ -17,18 +17,6 @@ package org.jboss.netty.channel.socket.nio; import static org.jboss.netty.channel.Channels.*; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelException; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.socket.Worker; -import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer; -import org.jboss.netty.logging.InternalLogger; -import org.jboss.netty.logging.InternalLoggerFactory; -import org.jboss.netty.util.ThreadRenamingRunnable; -import org.jboss.netty.util.internal.DeadLockProofWorker; -import org.jboss.netty.util.internal.QueueFactory; - import java.io.IOException; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.CancelledKeyException; @@ -47,8 +35,20 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelException; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.socket.Worker; +import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer; +import org.jboss.netty.logging.InternalLogger; +import org.jboss.netty.logging.InternalLoggerFactory; +import org.jboss.netty.util.ThreadRenamingRunnable; +import org.jboss.netty.util.internal.DeadLockProofWorker; +import org.jboss.netty.util.internal.QueueFactory; + abstract class AbstractNioWorker implements Worker { - + private static final AtomicInteger nextId = new AtomicInteger(); @@ -64,7 +64,7 @@ abstract class AbstractNioWorker implements Worker { static final int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, but won't need customization. - + /** * Executor used to execute {@link Runnable}s such as channel registration * task. @@ -117,7 +117,7 @@ abstract class AbstractNioWorker implements Worker { private final Queue eventQueue = QueueFactory.createQueue(Runnable.class); - + private volatile int cancelledKeys; // should use AtomicInteger but we just need approximation protected final SocketSendBufferPool sendBufferPool = new SocketSendBufferPool(); @@ -132,16 +132,16 @@ abstract class AbstractNioWorker implements Worker { this.executor = executor; this.allowShutdownOnIdle = allowShutdownOnIdle; } - + void register(AbstractNioChannel channel, ChannelFuture future) { Runnable registerTask = createRegisterTask(channel, future); Selector selector = start(); - + boolean offered = registerTaskQueue.offer(registerTask); assert offered; - + if (wakenUp.compareAndSet(false, true)) { selector.wakeup(); } @@ -149,7 +149,7 @@ abstract class AbstractNioWorker implements Worker { /** * Start the {@link AbstractNioWorker} and return the {@link Selector} that will be used for the {@link AbstractNioChannel}'s when they get registered - * + * * @return selector */ private Selector start() { @@ -157,7 +157,7 @@ abstract class AbstractNioWorker implements Worker { if (!started) { // Open a selector if this worker didn't start yet. try { - this.selector = Selector.open(); + selector = Selector.open(); } catch (Throwable t) { throw new ChannelException("Failed to create a selector.", t); } @@ -175,7 +175,7 @@ abstract class AbstractNioWorker implements Worker { } catch (Throwable t) { logger.warn("Failed to close a selector.", t); } - this.selector = null; + selector = null; // The method will return to the caller at this point. } } @@ -297,10 +297,10 @@ abstract class AbstractNioWorker implements Worker { public void executeInIoThread(Runnable task) { executeInIoThread(task, false); } - + /** * Execute the {@link Runnable} in a IO-Thread - * + * * @param task * the {@link Runnable} to execute * @param alwaysAsync @@ -325,8 +325,8 @@ abstract class AbstractNioWorker implements Worker { } } - - + + private void processRegisterTaskQueue() throws IOException { for (;;) { final Runnable task = registerTaskQueue.poll(); @@ -350,7 +350,7 @@ abstract class AbstractNioWorker implements Worker { cleanUpCancelledKeys(); } } - + private void processEventQueue() throws IOException { for (;;) { final Runnable task = eventQueue.poll(); @@ -361,7 +361,7 @@ abstract class AbstractNioWorker implements Worker { cleanUpCancelledKeys(); } } - + private void processSelectedKeys(Set selectedKeys) throws IOException { for (Iterator i = selectedKeys.iterator(); i.hasNext();) { SelectionKey k = i.next(); @@ -395,9 +395,9 @@ abstract class AbstractNioWorker implements Worker { } return false; } - - + + private void close(SelectionKey k) { AbstractNioChannel ch = (AbstractNioChannel) k.attachment(); close(ch, succeededFuture(ch)); @@ -431,7 +431,7 @@ abstract class AbstractNioWorker implements Worker { write0(ch); } } - + void writeFromSelectorLoop(final SelectionKey k) { AbstractNioChannel ch = (AbstractNioChannel) k.attachment(); ch.writeSuspended = false; @@ -552,7 +552,7 @@ abstract class AbstractNioWorker implements Worker { static boolean isIoThread(AbstractNioChannel channel) { return Thread.currentThread() == channel.worker.thread; } - + protected void setOpWrite(AbstractNioChannel channel) { Selector selector = this.selector; SelectionKey key = channel.channel.keyFor(selector); @@ -598,13 +598,13 @@ abstract class AbstractNioWorker implements Worker { } } } - + void close(AbstractNioChannel channel, ChannelFuture future) { boolean connected = channel.isConnected(); boolean bound = channel.isBound(); boolean iothread = isIoThread(channel); - + try { channel.channel.close(); cancelledKeys ++; @@ -688,7 +688,7 @@ abstract class AbstractNioWorker implements Worker { } evt.getFuture().setFailure(cause); - + } } @@ -714,16 +714,16 @@ abstract class AbstractNioWorker implements Worker { // Override OP_WRITE flag - a user cannot change this flag. interestOps &= ~Channel.OP_WRITE; interestOps |= channel.getRawInterestOps() & Channel.OP_WRITE; - + if (key == null || selector == null) { if (channel.getRawInterestOps() != interestOps) { changed = true; } - + // Not registered to the worker yet. // Set the rawInterestOps immediately; RegisterTask will pick it up. channel.setRawInterestOpsNow(interestOps); - + future.setSuccess(); if (changed) { if (iothread) { @@ -732,7 +732,7 @@ abstract class AbstractNioWorker implements Worker { fireChannelInterestChangedLater(channel); } } - + return; } @@ -802,7 +802,7 @@ abstract class AbstractNioWorker implements Worker { } } } - + /** * Read is called when a Selector has been notified that the underlying channel * was something to be read. The channel would previously have registered its interest @@ -814,11 +814,11 @@ abstract class AbstractNioWorker implements Worker { /** * Create a new {@link Runnable} which will register the {@link AbstractNioWorker} with the {@link Channel} - * + * * @param channel * @param future * @return task */ protected abstract Runnable createRegisterTask(AbstractNioChannel channel, ChannelFuture future); - + } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorkerPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorkerPool.java index 621c190fec..3f5a5ef6e9 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorkerPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/AbstractNioWorkerPool.java @@ -16,14 +16,14 @@ package org.jboss.netty.channel.socket.nio; +import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicInteger; + import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.socket.Worker; import org.jboss.netty.util.ExternalResourceReleasable; import org.jboss.netty.util.internal.ExecutorUtil; -import java.util.concurrent.Executor; -import java.util.concurrent.atomic.AtomicInteger; - /** * Abstract base class for {@link WorkerPool} implementations that create the {@link Worker}'s up-front and return them in a "fair" fashion when calling * {@link #nextWorker()} @@ -34,10 +34,10 @@ public abstract class AbstractNioWorkerPool impleme private final AbstractNioWorker[] workers; private final AtomicInteger workerIndex = new AtomicInteger(); private final Executor workerExecutor; - + /** * Create a new instance - * + * * @param workerExecutor the {@link Executor} to use for the {@link Worker}'s * @param allowShutdownOnIdle allow the {@link Worker}'s to shutdown when there is not {@link Channel} is registered with it * @param workerCount the count of {@link Worker}'s to create @@ -50,7 +50,7 @@ public abstract class AbstractNioWorkerPool impleme throw new IllegalArgumentException( "workerCount (" + workerCount + ") " + "must be a positive integer."); - } + } workers = new AbstractNioWorker[workerCount]; for (int i = 0; i < workers.length; i++) { @@ -62,11 +62,11 @@ public abstract class AbstractNioWorkerPool impleme /** * Create a new {@link Worker} which uses the given {@link Executor} to service IO - * - * + * + * * @param executor the {@link Executor} to use * @param allowShutdownOnIdle allow the {@link Worker} to shutdown when there is not {@link Channel} is registered with it - * @return worker the new {@link Worker} + * @return worker the new {@link Worker} */ protected abstract E createWorker(Executor executor, boolean allowShutdownOnIdle); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioAcceptedSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioAcceptedSocketChannel.java index fbfff17867..54af40e24b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioAcceptedSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioAcceptedSocketChannel.java @@ -15,7 +15,7 @@ */ package org.jboss.netty.channel.socket.nio; -import static org.jboss.netty.channel.Channels.fireChannelOpen; +import static org.jboss.netty.channel.Channels.*; import java.nio.channels.SocketChannel; @@ -38,7 +38,7 @@ final class NioAcceptedSocketChannel extends NioSocketChannel { this.bossThread = bossThread; setConnected(); - + fireChannelOpen(this); } } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java index 3212654bfe..e870a7232e 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java @@ -88,14 +88,14 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory private final NioClientSocketPipelineSink sink; /** - * Creates a new {@link NioClientSocketChannelFactory} which uses {@link Executors#newCachedThreadPool()} for the worker and boss executors. - * + * Creates a new {@link NioClientSocketChannelFactory} which uses {@link Executors#newCachedThreadPool()} for the worker and boss executors. + * * See {@link #NioClientSocketChannelFactory(Executor, Executor)} */ public NioClientSocketChannelFactory() { this(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); } - + /** * Creates a new instance. Calling this constructor is same with calling * {@link #NioClientSocketChannelFactory(Executor, Executor, int, int)} with @@ -163,7 +163,7 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory "bossCount (" + bossCount + ") " + "must be a positive integer."); } - + this.bossExecutor = bossExecutor; this.workerPool = workerPool; diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java index fccaef52bf..c5a44a3b99 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java @@ -15,18 +15,7 @@ */ package org.jboss.netty.channel.socket.nio; -import static org.jboss.netty.channel.Channels.fireChannelDisconnected; -import static org.jboss.netty.channel.Channels.fireChannelDisconnectedLater; -import static org.jboss.netty.channel.Channels.fireExceptionCaught; -import static org.jboss.netty.channel.Channels.fireExceptionCaughtLater; -import static org.jboss.netty.channel.Channels.fireMessageReceived; -import static org.jboss.netty.channel.Channels.succeededFuture; -import org.jboss.netty.buffer.ChannelBufferFactory; -import org.jboss.netty.channel.ChannelException; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.Channels; -import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.ReceiveBufferSizePredictor; +import static org.jboss.netty.channel.Channels.*; import java.io.IOException; import java.net.SocketAddress; @@ -39,6 +28,13 @@ import java.nio.channels.Selector; import java.util.Queue; import java.util.concurrent.Executor; +import org.jboss.netty.buffer.ChannelBufferFactory; +import org.jboss.netty.channel.ChannelException; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.ReceiveBufferSizePredictor; + /** * A class responsible for registering channels with {@link Selector}. * It also implements the {@link Selector} loop. @@ -58,7 +54,7 @@ public class NioDatagramWorker extends AbstractNioWorker { NioDatagramWorker(final Executor executor, boolean allowShutdownOnIdle) { super(executor, allowShutdownOnIdle); } - + @Override protected boolean read(final SelectionKey key) { final NioDatagramChannel channel = (NioDatagramChannel) key.attachment(); @@ -110,7 +106,7 @@ public class NioDatagramWorker extends AbstractNioWorker { return true; } - + @Override protected boolean scheduleWriteIfNecessary(final AbstractNioChannel channel) { @@ -163,7 +159,7 @@ public class NioDatagramWorker extends AbstractNioWorker { protected Runnable createRegisterTask(AbstractNioChannel channel, ChannelFuture future) { return new ChannelRegistionTask((NioDatagramChannel) channel, future); } - + /** * RegisterTask is a task responsible for registering a channel with a * selector. @@ -206,7 +202,7 @@ public class NioDatagramWorker extends AbstractNioWorker { future.setFailure(e); } close(channel, succeededFuture(channel)); - + if (!(e instanceof ClosedChannelException)) { throw new ChannelException( "Failed to register a socket to the selector.", e); @@ -214,7 +210,7 @@ public class NioDatagramWorker extends AbstractNioWorker { } } } - + @Override public void writeFromUserCode(final AbstractNioChannel channel) { /* @@ -243,7 +239,7 @@ public class NioDatagramWorker extends AbstractNioWorker { write0(channel); } - + @Override protected void write0(final AbstractNioChannel channel) { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorkerPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorkerPool.java index 87c3ef4d42..af71d9ec0b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorkerPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorkerPool.java @@ -20,7 +20,7 @@ import java.util.concurrent.Executor; /** * Default implementation which hands of {@link NioDatagramWorker}'s - * + * * */ public class NioDatagramWorkerPool extends AbstractNioWorkerPool { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java index 28109b1aec..da210b36b0 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java @@ -90,14 +90,14 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory private final ChannelSink sink; /** - * Create a new {@link NioServerSocketChannelFactory} using {@link Executors#newCachedThreadPool()} for the boss and worker. - * + * Create a new {@link NioServerSocketChannelFactory} using {@link Executors#newCachedThreadPool()} for the boss and worker. + * * See {@link #NioServerSocketChannelFactory(Executor, Executor)} */ public NioServerSocketChannelFactory() { this(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); } - + /** * Creates a new instance. Calling this constructor is same with calling * {@link #NioServerSocketChannelFactory(Executor, Executor, int)} with 2 * @@ -146,7 +146,7 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory if (workerPool == null) { throw new NullPointerException("workerPool"); } - + this.bossExecutor = bossExecutor; this.workerPool = workerPool; sink = new NioServerSocketPipelineSink(workerPool); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java index 427505fe79..f24996acdd 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java @@ -15,16 +15,7 @@ */ package org.jboss.netty.channel.socket.nio; -import static org.jboss.netty.channel.Channels.fireChannelBound; -import static org.jboss.netty.channel.Channels.fireChannelConnected; -import static org.jboss.netty.channel.Channels.fireExceptionCaught; -import static org.jboss.netty.channel.Channels.fireMessageReceived; -import static org.jboss.netty.channel.Channels.succeededFuture; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBufferFactory; -import org.jboss.netty.channel.ChannelException; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.ReceiveBufferSizePredictor; +import static org.jboss.netty.channel.Channels.*; import java.io.IOException; import java.net.SocketAddress; @@ -35,6 +26,12 @@ import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.concurrent.Executor; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBufferFactory; +import org.jboss.netty.channel.ChannelException; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ReceiveBufferSizePredictor; + public class NioWorker extends AbstractNioWorker { private final SocketReceiveBufferPool recvBufferPool = new SocketReceiveBufferPool(); @@ -42,7 +39,7 @@ public class NioWorker extends AbstractNioWorker { public NioWorker(Executor executor) { super(executor); } - + public NioWorker(Executor executor, boolean allowShutdownOnIdle) { super(executor, allowShutdownOnIdle); } @@ -141,13 +138,13 @@ public class NioWorker extends AbstractNioWorker { return false; } - + @Override protected Runnable createRegisterTask(AbstractNioChannel channel, ChannelFuture future) { boolean server = !(channel instanceof NioClientSocketChannel); return new RegisterTask((NioSocketChannel) channel, future, server); } - + private final class RegisterTask implements Runnable { private final NioSocketChannel channel; private final ChannelFuture future; @@ -186,7 +183,7 @@ public class NioWorker extends AbstractNioWorker { channel.setConnected(); future.setSuccess(); } - + if (server || !((NioClientSocketChannel) channel).boundManually) { fireChannelBound(channel, localAddress); } diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorkerPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorkerPool.java index be15bb469b..7e9f67a1dc 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorkerPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorkerPool.java @@ -20,7 +20,7 @@ import java.util.concurrent.Executor; /** * Default implementation which hands of {@link NioWorker}'s - * + * * */ public class NioWorkerPool extends AbstractNioWorkerPool { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/ShareableWorkerPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/ShareableWorkerPool.java index 114d151f7b..64f96b9ad6 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/ShareableWorkerPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/ShareableWorkerPool.java @@ -21,8 +21,8 @@ import org.jboss.netty.util.ExternalResourceReleasable; /** * This implementation of a {@link WorkerPool} should be used if you plan to share a {@link WorkerPool} between different Factories. You will need to call {@link #destroy()} by your own once * you want to release any resources of it. - * - * + * + * */ public final class ShareableWorkerPool implements WorkerPool { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java index d439e90a22..464c92df6d 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/SocketSendBufferPool.java @@ -72,7 +72,7 @@ final class SocketSendBufferPool { if (src instanceof CompositeChannelBuffer && DetectionUtil.javaVersion() >= 7) { return new GatheringSendBuffer(src.toByteBuffers()); } - + if (src.isDirect()) { return new UnpooledSendBuffer(src.toByteBuffer()); } @@ -257,7 +257,7 @@ final class SocketSendBufferPool { } } } - + class GatheringSendBuffer implements SendBuffer { private final ByteBuffer[] buffers; @@ -267,14 +267,14 @@ final class SocketSendBufferPool { GatheringSendBuffer(ByteBuffer[] buffers) { this.buffers = buffers; - this.last = buffers.length - 1; + last = buffers.length - 1; int total = 0; for (ByteBuffer buf: buffers) { total += buf.remaining(); } this.total = total; } - + public boolean finished() { return !buffers[last].hasRemaining(); } @@ -329,7 +329,7 @@ final class SocketSendBufferPool { public void release() { // nothing todo } - + } final class FileSendBuffer implements SendBuffer { diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/WorkerPool.java b/src/main/java/org/jboss/netty/channel/socket/nio/WorkerPool.java index 21a5681548..bf444576e5 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/WorkerPool.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/WorkerPool.java @@ -26,10 +26,10 @@ public interface WorkerPool { /** * Return the next {@link Worker} to use - * + * * @return worker */ E nextWorker(); - + } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioChannelSink.java b/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioChannelSink.java index 1eb70b9e71..456dcf4e93 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioChannelSink.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioChannelSink.java @@ -37,10 +37,10 @@ public abstract class AbstractOioChannelSink extends AbstractChannelSink { channel.worker.executeInIoThread(wrapper); return wrapper; } - } - + } + return super.execute(pipeline, task); - + } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioWorker.java index 8b3187f6f2..bc6ec6f672 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/AbstractOioWorker.java @@ -16,15 +16,16 @@ package org.jboss.netty.channel.socket.oio; import static org.jboss.netty.channel.Channels.*; + +import java.io.IOException; +import java.util.Queue; + import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.socket.Worker; import org.jboss.netty.util.internal.QueueFactory; -import java.io.IOException; -import java.util.Queue; - /** * Abstract base class for Oio-Worker implementations * @@ -33,7 +34,7 @@ import java.util.Queue; abstract class AbstractOioWorker implements Worker { private final Queue eventQueue = QueueFactory.createQueue(Runnable.class); - + protected final C channel; /** @@ -41,15 +42,15 @@ abstract class AbstractOioWorker implements Worker * used when starting. i.e. the current thread when the run method is executed. */ protected volatile Thread thread; - + private volatile boolean done; - + public AbstractOioWorker(C channel) { this.channel = channel; channel.worker = this; } - + public void run() { thread = channel.workerThread = Thread.currentThread(); @@ -67,7 +68,7 @@ abstract class AbstractOioWorker implements Worker } } } - + boolean cont = false; try { cont = process(); @@ -77,7 +78,7 @@ abstract class AbstractOioWorker implements Worker } } finally { processEventQueue(); - + if (!cont) { break; } @@ -90,37 +91,37 @@ abstract class AbstractOioWorker implements Worker // Clean up. close(channel, succeededFuture(channel), true); - + // Mark the worker event loop as done so we know that we need to run tasks directly and not queue them // See #287 done = true; - + // just to make we don't have something left processEventQueue(); } - + static boolean isIoThread(AbstractOioChannel channel) { return Thread.currentThread() == channel.workerThread; } - - + + public void executeInIoThread(Runnable task) { // check if the current thread is the worker thread // - // Also check if the event loop of the worker is complete. If so we need to run the task now. + // Also check if the event loop of the worker is complete. If so we need to run the task now. // See #287 if (Thread.currentThread() == thread || done) { task.run(); } else { boolean added = eventQueue.offer(task); - + if (added) { // as we set the SO_TIMEOUT to 1 second this task will get picked up in 1 second at latest } } } - + private void processEventQueue() { for (;;) { final Runnable task = eventQueue.poll(); @@ -130,21 +131,21 @@ abstract class AbstractOioWorker implements Worker task.run(); } } - + /** * Process the incoming messages and also is responsible for call {@link Channels#fireMessageReceived(Channel, Object)} once a message - * was processed without errors. - * + * was processed without errors. + * * @return continue returns true as long as this worker should continue to try processing incoming messages * @throws IOException */ abstract boolean process() throws IOException; - + static void setInterestOps( AbstractOioChannel channel, ChannelFuture future, int interestOps) { boolean iothread = isIoThread(channel); - + // Override OP_WRITE flag - a user cannot change this flag. interestOps &= ~Channel.OP_WRITE; interestOps |= channel.getInterestOps() & Channel.OP_WRITE; @@ -187,15 +188,15 @@ abstract class AbstractOioWorker implements Worker } } } - + static void close(AbstractOioChannel channel, ChannelFuture future) { close(channel, future, isIoThread(channel)); } - + private static void close(AbstractOioChannel channel, ChannelFuture future, boolean iothread) { boolean connected = channel.isConnected(); boolean bound = channel.isBound(); - + try { channel.closeSocket(); if (channel.setClosed()) { diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioAcceptedSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioAcceptedSocketChannel.java index 5f91e6b97e..cd278e9e24 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioAcceptedSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioAcceptedSocketChannel.java @@ -15,8 +15,7 @@ */ package org.jboss.netty.channel.socket.oio; -import static org.jboss.netty.channel.Channels.fireChannelBound; -import static org.jboss.netty.channel.Channels.fireChannelOpen; +import static org.jboss.netty.channel.Channels.*; import java.io.IOException; import java.io.OutputStream; @@ -53,7 +52,7 @@ class OioAcceptedSocketChannel extends OioSocketChannel { } catch (IOException e) { throw new ChannelException("Failed to obtain an OutputStream.", e); } - + fireChannelOpen(this); fireChannelBound(this, getLocalAddress()); } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java index 75eeb485c3..d00af816b6 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioClientSocketChannelFactory.java @@ -78,14 +78,14 @@ public class OioClientSocketChannelFactory implements ClientSocketChannelFactory final OioClientSocketPipelineSink sink; /** - * Creates a new instance with a {@link Executors#newCachedThreadPool()} as worker executor. - * + * Creates a new instance with a {@link Executors#newCachedThreadPool()} as worker executor. + * * See {@link #OioClientSocketChannelFactory(Executor)} */ public OioClientSocketChannelFactory() { this(Executors.newCachedThreadPool()); } - + /** * Creates a new instance. * diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java index 00231693f7..2ac95c9106 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannel.java @@ -61,7 +61,7 @@ final class OioDatagramChannel extends AbstractOioChannel "Failed to configure the datagram socket timeout.", e); } config = new DefaultDatagramChannelConfig(socket); - + fireChannelOpen(this); } @@ -147,6 +147,6 @@ final class OioDatagramChannel extends AbstractOioChannel boolean isSocketClosed() { return socket.isClosed(); } - - + + } diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java index c3b9eb3230..689d2bff51 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramChannelFactory.java @@ -78,13 +78,13 @@ public class OioDatagramChannelFactory implements DatagramChannelFactory { /** * Creates a new instance with a {@link Executors#newCachedThreadPool()} - * + * * See {@link #OioDatagramChannelFactory(Executor)} */ public OioDatagramChannelFactory() { this(Executors.newCachedThreadPool()); } - + /** * Creates a new instance. * diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java index 2ecc8b0302..da508ae994 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java @@ -33,7 +33,7 @@ class OioDatagramWorker extends AbstractOioWorker { super(channel); } - + @Override boolean process() throws IOException { @@ -49,7 +49,7 @@ class OioDatagramWorker extends AbstractOioWorker { // Can happen on interruption. // Keep receiving unless the channel is closed. return true; - } + } fireMessageReceived( channel, @@ -64,7 +64,7 @@ class OioDatagramWorker extends AbstractOioWorker { OioDatagramChannel channel, ChannelFuture future, Object message, SocketAddress remoteAddress) { boolean iothread = isIoThread(channel); - + try { ChannelBuffer buf = (ChannelBuffer) message; int offset = buf.readerIndex(); @@ -102,11 +102,11 @@ class OioDatagramWorker extends AbstractOioWorker { } } - + static void disconnect(OioDatagramChannel channel, ChannelFuture future) { boolean connected = channel.isConnected(); boolean iothread = isIoThread(channel); - + try { channel.socket.disconnect(); future.setSuccess(); diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java index 4ba50664ac..ef39120979 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannel.java @@ -68,7 +68,7 @@ class OioServerSocketChannel extends AbstractServerChannel logger.warn( "Failed to close a partially initialized socket.", e2); } - + } throw new ChannelException( "Failed to set the server socket timeout.", e); diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java index 11ce5803f5..e8bca7c15b 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioServerSocketChannelFactory.java @@ -92,13 +92,13 @@ public class OioServerSocketChannelFactory implements ServerSocketChannelFactory /** * Create a new {@link OioServerSocketChannelFactory} with a {@link Executors#newCachedThreadPool()} for the boss and worker executor. - * + * * See {@link #OioServerSocketChannelFactory(Executor, Executor)} */ public OioServerSocketChannelFactory() { this(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); } - + /** * Creates a new instance. * diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java index a05f37d676..e89568b005 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java @@ -47,7 +47,7 @@ class OioWorker extends AbstractOioWorker { // Fire the channelConnected event for OioAcceptedSocketChannel. // See #287 fireChannelConnected(channel, channel.getRemoteAddress()); - + } super.run(); } @@ -70,7 +70,7 @@ class OioWorker extends AbstractOioWorker { return true; } fireMessageReceived(channel, channel.getConfig().getBufferFactory().getBuffer(buf, 0, readBytes)); - + return true; } @@ -94,14 +94,14 @@ class OioWorker extends AbstractOioWorker { try { int length = 0; - // Add support to write a FileRegion. This in fact will not give any performance gain but at least it not fail and + // Add support to write a FileRegion. This in fact will not give any performance gain but at least it not fail and // we did the best to emulate it if (message instanceof FileRegion) { FileRegion fr = (FileRegion) message; try { synchronized (out) { WritableByteChannel bchannel = Channels.newChannel(out); - + long i = 0; while ((i = fr.transferTo(bchannel, length)) > 0) { length += i; @@ -126,14 +126,14 @@ class OioWorker extends AbstractOioWorker { a.getBytes(a.readerIndex(), out, length); } } - + future.setSuccess(); if (iothread) { fireWriteComplete(channel, length); } else { fireWriteCompleteLater(channel, length); } - + } catch (Throwable t) { // Convert 'SocketException: Socket closed' to // ClosedChannelException. diff --git a/src/main/java/org/jboss/netty/example/discard/DiscardServer.java b/src/main/java/org/jboss/netty/example/discard/DiscardServer.java index 6b12314b43..dc245a0521 100644 --- a/src/main/java/org/jboss/netty/example/discard/DiscardServer.java +++ b/src/main/java/org/jboss/netty/example/discard/DiscardServer.java @@ -34,7 +34,7 @@ public class DiscardServer { public DiscardServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/echo/EchoServer.java b/src/main/java/org/jboss/netty/example/echo/EchoServer.java index 5bf0153efa..9ecd55c292 100644 --- a/src/main/java/org/jboss/netty/example/echo/EchoServer.java +++ b/src/main/java/org/jboss/netty/example/echo/EchoServer.java @@ -30,11 +30,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; public class EchoServer { private final int port; - + public EchoServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/factorial/FactorialClient.java b/src/main/java/org/jboss/netty/example/factorial/FactorialClient.java index 95dc08d863..6872d7f7fd 100644 --- a/src/main/java/org/jboss/netty/example/factorial/FactorialClient.java +++ b/src/main/java/org/jboss/netty/example/factorial/FactorialClient.java @@ -32,7 +32,7 @@ public class FactorialClient { 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; diff --git a/src/main/java/org/jboss/netty/example/factorial/FactorialServer.java b/src/main/java/org/jboss/netty/example/factorial/FactorialServer.java index 2cfa7802d1..ca63f47ab0 100644 --- a/src/main/java/org/jboss/netty/example/factorial/FactorialServer.java +++ b/src/main/java/org/jboss/netty/example/factorial/FactorialServer.java @@ -28,11 +28,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; public class FactorialServer { private final int port; - + public FactorialServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServer.java b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServer.java index c9099da9d6..945a9accb9 100644 --- a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServer.java +++ b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServer.java @@ -22,13 +22,13 @@ import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; public class HttpStaticFileServer { - + private final int port; - + public HttpStaticFileServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopClient.java b/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopClient.java index 9099f59802..2872603391 100644 --- a/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopClient.java +++ b/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopClient.java @@ -37,7 +37,7 @@ import org.jboss.netty.handler.codec.http.HttpVersion; public class HttpSnoopClient { private final URI uri; - + public HttpSnoopClient(URI uri) { this.uri = uri; } diff --git a/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopServer.java b/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopServer.java index 909359aeb2..264f84373a 100644 --- a/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopServer.java +++ b/src/main/java/org/jboss/netty/example/http/snoop/HttpSnoopServer.java @@ -26,7 +26,7 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; * in a pretty plaintext form. */ public class HttpSnoopServer { - + private final int port; public HttpSnoopServer(int port) { diff --git a/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java b/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java index f3e04ab328..58b1cb2dfd 100644 --- a/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java +++ b/src/main/java/org/jboss/netty/example/http/tunnel/HttpTunnelingClientExample.java @@ -44,7 +44,7 @@ import org.jboss.netty.logging.InternalLogLevel; public class HttpTunnelingClientExample { private final URI uri; - + public HttpTunnelingClientExample(URI uri) { this.uri = uri; } diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClient.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClient.java index c708f3d634..85a103b4ae 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClient.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClient.java @@ -31,27 +31,27 @@ import org.jboss.netty.handler.codec.http.CookieEncoder; import org.jboss.netty.handler.codec.http.DefaultHttpRequest; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpMethod; +import org.jboss.netty.handler.codec.http.HttpRequest; +import org.jboss.netty.handler.codec.http.HttpVersion; +import org.jboss.netty.handler.codec.http.QueryStringEncoder; import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory; import org.jboss.netty.handler.codec.http.multipart.DiskAttribute; import org.jboss.netty.handler.codec.http.multipart.DiskFileUpload; import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder; -import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder.ErrorDataEncoderException; -import org.jboss.netty.handler.codec.http.HttpRequest; -import org.jboss.netty.handler.codec.http.HttpVersion; -import org.jboss.netty.handler.codec.http.QueryStringEncoder; +import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData; import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLoggerFactory; public class HttpUploadClient { - + private static final InternalLogger logger = InternalLoggerFactory.getInstance(HttpUploadClient.class); - + private final String baseUri; private final String filePath; - + public HttpUploadClient(String baseUri, String filePath) { this.baseUri = baseUri; this.filePath = filePath; diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientHandler.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientHandler.java index 8306e37111..46e00186bb 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientHandler.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientHandler.java @@ -27,7 +27,7 @@ import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.util.CharsetUtil; public class HttpUploadClientHandler extends SimpleChannelUpstreamHandler { - + private static final InternalLogger logger = InternalLoggerFactory.getInstance(HttpUploadClientHandler.class); diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientPipelineFactory.java index 6bc743cd58..4cf38810d1 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadClientPipelineFactory.java @@ -54,7 +54,7 @@ public class HttpUploadClientPipelineFactory implements ChannelPipelineFactory { // to be used since huge file transfer pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); - + pipeline.addLast("handler", new HttpUploadClientHandler()); return pipeline; } diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServer.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServer.java index b6bb88614f..e24528f214 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServer.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServer.java @@ -22,13 +22,13 @@ import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; public class HttpUploadServer { - + private final int port; - + public HttpUploadServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerHandler.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerHandler.java index b6df1d125f..fdb97746ca 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerHandler.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerHandler.java @@ -44,6 +44,7 @@ import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; +import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.jboss.netty.handler.codec.http.multipart.Attribute; import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory; import org.jboss.netty.handler.codec.http.multipart.DiskAttribute; @@ -51,13 +52,12 @@ import org.jboss.netty.handler.codec.http.multipart.DiskFileUpload; import org.jboss.netty.handler.codec.http.multipart.FileUpload; import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder; -import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException; import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException; +import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData; import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType; -import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.util.CharsetUtil; diff --git a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerPipelineFactory.java index e81df7ee03..8991d70485 100644 --- a/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/upload/HttpUploadServerPipelineFactory.java @@ -15,7 +15,7 @@ */ package org.jboss.netty.example.http.upload; -import static org.jboss.netty.channel.Channels.pipeline; +import static org.jboss.netty.channel.Channels.*; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineFactory; diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/AutobahnServer.java b/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/AutobahnServer.java index 229788352e..39501e68fc 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/AutobahnServer.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/AutobahnServer.java @@ -26,13 +26,13 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; * suite */ public class AutobahnServer { - + private final int port; public AutobahnServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/package-info.java b/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/package-info.java index cc77117120..7152c0abbf 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/package-info.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/autobahn/package-info.java @@ -15,28 +15,28 @@ */ /** - * This package is intended for use with testing against the Python + * This package is intended for use with testing against the Python * AutoBahn test suite. * *

How to run the tests on Ubuntu

- * + * *

01. Add ppa:twisted-dev/ppa to your system's Software Sources - * + * *

02. Install Twisted V11: sudo apt-get install python-twisted - * + * *

03. Intall Python Setup Tools: sudo apt-get install python-setuptools - * + * *

04. Install AutoBahn: sudo easy_install Autobahn. If you already have Autobahn installed, you may need * to upgrade it: sudo easy_install --upgrade Autobahn. Make suer v0.4.10 is installed. - * + * *

05. Get AutoBahn testsuite source code: git clone git@github.com:tavendo/AutobahnPython.git - * + * *

06. Go to AutoBahn directory: cd AutobahnPython - * + * *

07. Checkout stable version: git checkout v0.4.10 - * + * *

08. Go to test suite directory: cd testsuite/websockets - * + * *

09. Edit fuzzing_clinet_spec.json and set the hybi specification version to 10 or 17 (RFC 6455). * * { @@ -47,14 +47,14 @@ * "exclude-agent-cases": {"FoobarServer*": ["4.*", "1.1.3"]} * } * - * - *

10. Run our AutobahnServer located in this package. If you are in Eclipse IDE, right click on + * + *

10. Run our AutobahnServer located in this package. If you are in Eclipse IDE, right click on * AutobahnServer.java and select Run As > Java Application. - * - *

11. Run the Autobahn test python fuzzing_client.py. Note that the actual test case python code is + * + *

11. Run the Autobahn test python fuzzing_client.py. Note that the actual test case python code is * located with the easy_install package (e.g. in /usr/local/lib/python2.7/dist-packages/ * autobahn-0.4.10-py2.7.egg/autobahn/cases) and not in the checked out git repository. - * + * *

12. See the results in reports/servers/index.html */ package org.jboss.netty.example.http.websocketx.autobahn; diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/server/WebSocketServer.java b/src/main/java/org/jboss/netty/example/http/websocketx/server/WebSocketServer.java index 4f0f4295c4..c2cc73084a 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/server/WebSocketServer.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/server/WebSocketServer.java @@ -23,14 +23,14 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; /** * A HTTP server which serves Web Socket requests at: - * + * * http://localhost:8080/websocket - * + * * Open your browser at http://localhost:8080/, then the demo page will be loaded and a Web Socket connection will be * made automatically. - * + * * This server illustrates support for the different web socket specification versions and will work with: - * + * *

    *
  • Safari 5+ (draft-ietf-hybi-thewebsocketprotocol-00) *
  • Chrome 6-13 (draft-ietf-hybi-thewebsocketprotocol-00) @@ -41,13 +41,13 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; *
*/ public class WebSocketServer { - + private final int port; - + public WebSocketServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/server/package-info.java b/src/main/java/org/jboss/netty/example/http/websocketx/server/package-info.java index 5826ea15c8..48085d8ec7 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/server/package-info.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/server/package-info.java @@ -16,12 +16,12 @@ /** *

This package contains an example web socket web server. - *

The web server only handles text, ping and closing frames. For text frames, + *

The web server only handles text, ping and closing frames. For text frames, * it echoes the received text in upper case. - *

Once started, you can test the web server against your browser by navigating + *

Once started, you can test the web server against your browser by navigating * to http://localhost:8080/ - *

You can also test it with a web socket client. Send web socket traffic to - * ws://localhost:8080/websocket. + *

You can also test it with a web socket client. Send web socket traffic to + * ws://localhost:8080/websocket. */ package org.jboss.netty.example.http.websocketx.server; diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServer.java b/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServer.java index dcff82f62f..e4b3724305 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServer.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServer.java @@ -23,14 +23,14 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; /** * A HTTP server which serves Web Socket requests at: - * + * * https://localhost:8081/websocket - * + * * Open your browser at https://localhost:8081/, then the demo page will be loaded and a Web Socket connection will be * made automatically. - * + * * This server illustrates support for the different web socket specification versions and will work with: - * + * *

    *
  • Safari 5+ (draft-ietf-hybi-thewebsocketprotocol-00) *
  • Chrome 6-13 (draft-ietf-hybi-thewebsocketprotocol-00) @@ -40,7 +40,7 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; *
*/ public class WebSocketSslServer { - + private final int port; public WebSocketSslServer(int port) { @@ -81,7 +81,7 @@ public class WebSocketSslServer { System.out.println("ERROR: System property keystore.file.password not set. Exiting now!"); System.exit(1); } - + new WebSocketSslServer(port).run(); } } diff --git a/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServerSslContext.java b/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServerSslContext.java index 337c800dab..74cd721045 100644 --- a/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServerSslContext.java +++ b/src/main/java/org/jboss/netty/example/http/websocketx/sslserver/WebSocketSslServerSslContext.java @@ -44,7 +44,7 @@ public final class WebSocketSslServerSslContext { /** * SingletonHolder is loaded on the first execution of Singleton.getInstance() or the first access to * SingletonHolder.INSTANCE, not before. - * + * * See http://en.wikipedia.org/wiki/Singleton_pattern */ private static class SingletonHolder { diff --git a/src/main/java/org/jboss/netty/example/local/LocalExample.java b/src/main/java/org/jboss/netty/example/local/LocalExample.java index 52e321e215..805bedacbc 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalExample.java +++ b/src/main/java/org/jboss/netty/example/local/LocalExample.java @@ -37,7 +37,7 @@ import org.jboss.netty.logging.InternalLogLevel; public class LocalExample { private final String port; - + public LocalExample(String port) { this.port = port; } diff --git a/src/main/java/org/jboss/netty/example/local/LocalExampleMultithreaded.java b/src/main/java/org/jboss/netty/example/local/LocalExampleMultithreaded.java index 9c01ea42d8..ce747151ec 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalExampleMultithreaded.java +++ b/src/main/java/org/jboss/netty/example/local/LocalExampleMultithreaded.java @@ -35,7 +35,7 @@ import org.jboss.netty.logging.InternalLogLevel; public class LocalExampleMultithreaded { private final String port; - + public LocalExampleMultithreaded(String port) { this.port = port; } diff --git a/src/main/java/org/jboss/netty/example/localtime/LocalTimeClient.java b/src/main/java/org/jboss/netty/example/localtime/LocalTimeClient.java index f2ca6a805e..6480829a74 100644 --- a/src/main/java/org/jboss/netty/example/localtime/LocalTimeClient.java +++ b/src/main/java/org/jboss/netty/example/localtime/LocalTimeClient.java @@ -36,7 +36,7 @@ public class LocalTimeClient { private final String host; private final int port; private final Collection cities; - + public LocalTimeClient(String host, int port, Collection cities) { this.host = host; this.port = port; diff --git a/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.java b/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.java index 6b5ae29c54..00fb97a091 100644 --- a/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.java +++ b/src/main/java/org/jboss/netty/example/localtime/LocalTimeProtocol.java @@ -39,7 +39,7 @@ public final class LocalTimeProtocol { MIDEAST(9, 9), PACIFIC(10, 10), ; - + public static final int AFRICA_VALUE = 0; public static final int AMERICA_VALUE = 1; public static final int ANTARCTICA_VALUE = 2; @@ -51,10 +51,10 @@ public final class LocalTimeProtocol { public static final int INDIAN_VALUE = 8; public static final int MIDEAST_VALUE = 9; public static final int PACIFIC_VALUE = 10; - - + + public final int getNumber() { return value; } - + public static Continent valueOf(int value) { switch (value) { case 0: return AFRICA; @@ -71,7 +71,7 @@ public final class LocalTimeProtocol { default: return null; } } - + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { return internalValueMap; @@ -83,7 +83,7 @@ public final class LocalTimeProtocol { return Continent.valueOf(number); } }; - + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { return getDescriptor().getValues().get(index); @@ -96,11 +96,11 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.getDescriptor().getEnumTypes().get(0); } - + private static final Continent[] VALUES = { - AFRICA, AMERICA, ANTARCTICA, ARCTIC, ASIA, ATLANTIC, AUSTRALIA, EUROPE, INDIAN, MIDEAST, PACIFIC, + AFRICA, AMERICA, ANTARCTICA, ARCTIC, ASIA, ATLANTIC, AUSTRALIA, EUROPE, INDIAN, MIDEAST, PACIFIC, }; - + public static Continent valueOf( com.google.protobuf.Descriptors.EnumValueDescriptor desc) { if (desc.getType() != getDescriptor()) { @@ -109,18 +109,18 @@ public final class LocalTimeProtocol { } return VALUES[desc.getIndex()]; } - + private final int index; private final int value; - + private Continent(int index, int value) { this.index = index; this.value = value; } - + // @@protoc_insertion_point(enum_scope:org.jboss.netty.example.localtime.Continent) } - + public enum DayOfWeek implements com.google.protobuf.ProtocolMessageEnum { SUNDAY(0, 1), @@ -131,7 +131,7 @@ public final class LocalTimeProtocol { FRIDAY(5, 6), SATURDAY(6, 7), ; - + public static final int SUNDAY_VALUE = 1; public static final int MONDAY_VALUE = 2; public static final int TUESDAY_VALUE = 3; @@ -139,10 +139,10 @@ public final class LocalTimeProtocol { public static final int THURSDAY_VALUE = 5; public static final int FRIDAY_VALUE = 6; public static final int SATURDAY_VALUE = 7; - - + + public final int getNumber() { return value; } - + public static DayOfWeek valueOf(int value) { switch (value) { case 1: return SUNDAY; @@ -155,7 +155,7 @@ public final class LocalTimeProtocol { default: return null; } } - + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { return internalValueMap; @@ -167,7 +167,7 @@ public final class LocalTimeProtocol { return DayOfWeek.valueOf(number); } }; - + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { return getDescriptor().getValues().get(index); @@ -180,11 +180,11 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.getDescriptor().getEnumTypes().get(1); } - + private static final DayOfWeek[] VALUES = { - SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, }; - + public static DayOfWeek valueOf( com.google.protobuf.Descriptors.EnumValueDescriptor desc) { if (desc.getType() != getDescriptor()) { @@ -193,25 +193,25 @@ public final class LocalTimeProtocol { } return VALUES[desc.getIndex()]; } - + private final int index; private final int value; - + private DayOfWeek(int index, int value) { this.index = index; this.value = value; } - + // @@protoc_insertion_point(enum_scope:org.jboss.netty.example.localtime.DayOfWeek) } - + public interface LocationOrBuilder extends com.google.protobuf.MessageOrBuilder { - + // required .org.jboss.netty.example.localtime.Continent continent = 1; boolean hasContinent(); org.jboss.netty.example.localtime.LocalTimeProtocol.Continent getContinent(); - + // required string city = 2; boolean hasCity(); String getCity(); @@ -224,49 +224,49 @@ public final class LocalTimeProtocol { super(builder); } private Location(boolean noInit) {} - + private static final Location defaultInstance; public static Location getDefaultInstance() { return defaultInstance; } - + public Location getDefaultInstanceForType() { return defaultInstance; } - + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Location_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Location_fieldAccessorTable; } - + private int bitField0_; // required .org.jboss.netty.example.localtime.Continent continent = 1; public static final int CONTINENT_FIELD_NUMBER = 1; private org.jboss.netty.example.localtime.LocalTimeProtocol.Continent continent_; public boolean hasContinent() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return (bitField0_ & 0x00000001) == 0x00000001; } public org.jboss.netty.example.localtime.LocalTimeProtocol.Continent getContinent() { return continent_; } - + // required string city = 2; public static final int CITY_FIELD_NUMBER = 2; private java.lang.Object city_; public boolean hasCity() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return (bitField0_ & 0x00000002) == 0x00000002; } public String getCity() { java.lang.Object ref = city_; if (ref instanceof String) { return (String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; String s = bs.toStringUtf8(); if (com.google.protobuf.Internal.isValidUtf8(bs)) { @@ -278,7 +278,7 @@ public final class LocalTimeProtocol { private com.google.protobuf.ByteString getCityBytes() { java.lang.Object ref = city_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); city_ = b; return b; @@ -286,7 +286,7 @@ public final class LocalTimeProtocol { return (com.google.protobuf.ByteString) ref; } } - + private void initFields() { continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA; city_ = ""; @@ -294,8 +294,10 @@ public final class LocalTimeProtocol { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - + if (isInitialized != -1) { + return isInitialized == 1; + } + if (!hasContinent()) { memoizedIsInitialized = 0; return false; @@ -307,30 +309,32 @@ public final class LocalTimeProtocol { memoizedIsInitialized = 1; return true; } - + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { output.writeEnum(1, continent_.getNumber()); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if ((bitField0_ & 0x00000002) == 0x00000002) { output.writeBytes(2, getCityBytes()); } getUnknownFields().writeTo(output); } - + private int memoizedSerializedSize = -1; public int getSerializedSize() { int size = memoizedSerializedSize; - if (size != -1) return size; - + if (size != -1) { + return size; + } + size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(1, continent_.getNumber()); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if ((bitField0_ & 0x00000002) == 0x00000002) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, getCityBytes()); } @@ -338,14 +342,14 @@ public final class LocalTimeProtocol { memoizedSerializedSize = size; return size; } - + private static final long serialVersionUID = 0L; @java.lang.Override protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { return super.writeReplace(); } - + public static org.jboss.netty.example.localtime.LocalTimeProtocol.Location parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { @@ -412,14 +416,14 @@ public final class LocalTimeProtocol { return newBuilder().mergeFrom(input, extensionRegistry) .buildParsed(); } - + public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.jboss.netty.example.localtime.LocalTimeProtocol.Location prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } - + @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { @@ -433,17 +437,17 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Location_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Location_fieldAccessorTable; } - + // Construct using org.jboss.netty.example.localtime.LocalTimeProtocol.Location.newBuilder() private Builder() { maybeForceBuilderInitialization(); } - + private Builder(BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); @@ -455,29 +459,29 @@ public final class LocalTimeProtocol { private static Builder create() { return new Builder(); } - + public Builder clear() { super.clear(); continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA; - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; city_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = bitField0_ & ~0x00000002; return this; } - + public Builder clone() { return create().mergeFrom(buildPartial()); } - + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDescriptor(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Location getDefaultInstanceForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Location build() { org.jboss.netty.example.localtime.LocalTimeProtocol.Location result = buildPartial(); if (!result.isInitialized()) { @@ -485,7 +489,7 @@ public final class LocalTimeProtocol { } return result; } - + private org.jboss.netty.example.localtime.LocalTimeProtocol.Location buildParsed() throws com.google.protobuf.InvalidProtocolBufferException { org.jboss.netty.example.localtime.LocalTimeProtocol.Location result = buildPartial(); @@ -495,16 +499,16 @@ public final class LocalTimeProtocol { } return result; } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Location buildPartial() { org.jboss.netty.example.localtime.LocalTimeProtocol.Location result = new org.jboss.netty.example.localtime.LocalTimeProtocol.Location(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + if ((from_bitField0_ & 0x00000001) == 0x00000001) { to_bitField0_ |= 0x00000001; } result.continent_ = continent_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + if ((from_bitField0_ & 0x00000002) == 0x00000002) { to_bitField0_ |= 0x00000002; } result.city_ = city_; @@ -512,7 +516,7 @@ public final class LocalTimeProtocol { onBuilt(); return result; } - + public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jboss.netty.example.localtime.LocalTimeProtocol.Location) { return mergeFrom((org.jboss.netty.example.localtime.LocalTimeProtocol.Location)other); @@ -521,49 +525,51 @@ public final class LocalTimeProtocol { return this; } } - + public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.Location other) { - if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance()) return this; + if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance()) { + return this; + } if (other.hasContinent()) { setContinent(other.getContinent()); } if (other.hasCity()) { setCity(other.getCity()); } - this.mergeUnknownFields(other.getUnknownFields()); + mergeUnknownFields(other.getUnknownFields()); return this; } - + public final boolean isInitialized() { if (!hasContinent()) { - + return false; } if (!hasCity()) { - + return false; } return true; } - + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); + getUnknownFields()); while (true) { int tag = input.readTag(); switch (tag) { case 0: - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; } @@ -588,13 +594,13 @@ public final class LocalTimeProtocol { } } } - + private int bitField0_; - + // required .org.jboss.netty.example.localtime.Continent continent = 1; private org.jboss.netty.example.localtime.LocalTimeProtocol.Continent continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA; public boolean hasContinent() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return (bitField0_ & 0x00000001) == 0x00000001; } public org.jboss.netty.example.localtime.LocalTimeProtocol.Continent getContinent() { return continent_; @@ -609,16 +615,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearContinent() { - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA; onChanged(); return this; } - + // required string city = 2; private java.lang.Object city_ = ""; public boolean hasCity() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return (bitField0_ & 0x00000002) == 0x00000002; } public String getCity() { java.lang.Object ref = city_; @@ -640,7 +646,7 @@ public final class LocalTimeProtocol { return this; } public Builder clearCity() { - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = bitField0_ & ~0x00000002; city_ = getDefaultInstance().getCity(); onChanged(); return this; @@ -650,27 +656,27 @@ public final class LocalTimeProtocol { city_ = value; onChanged(); } - + // @@protoc_insertion_point(builder_scope:org.jboss.netty.example.localtime.Location) } - + static { defaultInstance = new Location(true); defaultInstance.initFields(); } - + // @@protoc_insertion_point(class_scope:org.jboss.netty.example.localtime.Location) } - + public interface LocationsOrBuilder extends com.google.protobuf.MessageOrBuilder { - + // repeated .org.jboss.netty.example.localtime.Location location = 1; - java.util.List + java.util.List getLocationList(); org.jboss.netty.example.localtime.LocalTimeProtocol.Location getLocation(int index); int getLocationCount(); - java.util.List + java.util.List getLocationOrBuilderList(); org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder getLocationOrBuilder( int index); @@ -683,33 +689,33 @@ public final class LocalTimeProtocol { super(builder); } private Locations(boolean noInit) {} - + private static final Locations defaultInstance; public static Locations getDefaultInstance() { return defaultInstance; } - + public Locations getDefaultInstanceForType() { return defaultInstance; } - + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Locations_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Locations_fieldAccessorTable; } - + // repeated .org.jboss.netty.example.localtime.Location location = 1; public static final int LOCATION_FIELD_NUMBER = 1; private java.util.List location_; public java.util.List getLocationList() { return location_; } - public java.util.List + public java.util.List getLocationOrBuilderList() { return location_; } @@ -723,15 +729,17 @@ public final class LocalTimeProtocol { int index) { return location_.get(index); } - + private void initFields() { location_ = java.util.Collections.emptyList(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - + if (isInitialized != -1) { + return isInitialized == 1; + } + for (int i = 0; i < getLocationCount(); i++) { if (!getLocation(i).isInitialized()) { memoizedIsInitialized = 0; @@ -741,7 +749,7 @@ public final class LocalTimeProtocol { memoizedIsInitialized = 1; return true; } - + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); @@ -750,12 +758,14 @@ public final class LocalTimeProtocol { } getUnknownFields().writeTo(output); } - + private int memoizedSerializedSize = -1; public int getSerializedSize() { int size = memoizedSerializedSize; - if (size != -1) return size; - + if (size != -1) { + return size; + } + size = 0; for (int i = 0; i < location_.size(); i++) { size += com.google.protobuf.CodedOutputStream @@ -765,14 +775,14 @@ public final class LocalTimeProtocol { memoizedSerializedSize = size; return size; } - + private static final long serialVersionUID = 0L; @java.lang.Override protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { return super.writeReplace(); } - + public static org.jboss.netty.example.localtime.LocalTimeProtocol.Locations parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { @@ -839,14 +849,14 @@ public final class LocalTimeProtocol { return newBuilder().mergeFrom(input, extensionRegistry) .buildParsed(); } - + public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.jboss.netty.example.localtime.LocalTimeProtocol.Locations prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } - + @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { @@ -860,17 +870,17 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Locations_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_Locations_fieldAccessorTable; } - + // Construct using org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.newBuilder() private Builder() { maybeForceBuilderInitialization(); } - + private Builder(BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); @@ -883,31 +893,31 @@ public final class LocalTimeProtocol { private static Builder create() { return new Builder(); } - + public Builder clear() { super.clear(); if (locationBuilder_ == null) { location_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } else { locationBuilder_.clear(); } return this; } - + public Builder clone() { return create().mergeFrom(buildPartial()); } - + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDescriptor(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Locations getDefaultInstanceForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDefaultInstance(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Locations build() { org.jboss.netty.example.localtime.LocalTimeProtocol.Locations result = buildPartial(); if (!result.isInitialized()) { @@ -915,7 +925,7 @@ public final class LocalTimeProtocol { } return result; } - + private org.jboss.netty.example.localtime.LocalTimeProtocol.Locations buildParsed() throws com.google.protobuf.InvalidProtocolBufferException { org.jboss.netty.example.localtime.LocalTimeProtocol.Locations result = buildPartial(); @@ -925,14 +935,14 @@ public final class LocalTimeProtocol { } return result; } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.Locations buildPartial() { org.jboss.netty.example.localtime.LocalTimeProtocol.Locations result = new org.jboss.netty.example.localtime.LocalTimeProtocol.Locations(this); int from_bitField0_ = bitField0_; if (locationBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { location_ = java.util.Collections.unmodifiableList(location_); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } result.location_ = location_; } else { @@ -941,7 +951,7 @@ public final class LocalTimeProtocol { onBuilt(); return result; } - + public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jboss.netty.example.localtime.LocalTimeProtocol.Locations) { return mergeFrom((org.jboss.netty.example.localtime.LocalTimeProtocol.Locations)other); @@ -950,14 +960,16 @@ public final class LocalTimeProtocol { return this; } } - + public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.Locations other) { - if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDefaultInstance()) return this; + if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDefaultInstance()) { + return this; + } if (locationBuilder_ == null) { if (!other.location_.isEmpty()) { if (location_.isEmpty()) { location_ = other.location_; - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } else { ensureLocationIsMutable(); location_.addAll(other.location_); @@ -970,8 +982,8 @@ public final class LocalTimeProtocol { locationBuilder_.dispose(); locationBuilder_ = null; location_ = other.location_; - bitField0_ = (bitField0_ & ~0x00000001); - locationBuilder_ = + bitField0_ = bitField0_ & ~0x00000001; + locationBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getLocationFieldBuilder() : null; } else { @@ -979,38 +991,38 @@ public final class LocalTimeProtocol { } } } - this.mergeUnknownFields(other.getUnknownFields()); + mergeUnknownFields(other.getUnknownFields()); return this; } - + public final boolean isInitialized() { for (int i = 0; i < getLocationCount(); i++) { if (!getLocation(i).isInitialized()) { - + return false; } } return true; } - + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); + getUnknownFields()); while (true) { int tag = input.readTag(); switch (tag) { case 0: - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; } @@ -1025,9 +1037,9 @@ public final class LocalTimeProtocol { } } } - + private int bitField0_; - + // repeated .org.jboss.netty.example.localtime.Location location = 1; private java.util.List location_ = java.util.Collections.emptyList(); @@ -1037,10 +1049,10 @@ public final class LocalTimeProtocol { bitField0_ |= 0x00000001; } } - + private com.google.protobuf.RepeatedFieldBuilder< org.jboss.netty.example.localtime.LocalTimeProtocol.Location, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder> locationBuilder_; - + public java.util.List getLocationList() { if (locationBuilder_ == null) { return java.util.Collections.unmodifiableList(location_); @@ -1150,7 +1162,7 @@ public final class LocalTimeProtocol { public Builder clearLocation() { if (locationBuilder_ == null) { location_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; onChanged(); } else { locationBuilder_.clear(); @@ -1178,7 +1190,7 @@ public final class LocalTimeProtocol { return locationBuilder_.getMessageOrBuilder(index); } } - public java.util.List + public java.util.List getLocationOrBuilderList() { if (locationBuilder_ != null) { return locationBuilder_.getMessageOrBuilderList(); @@ -1195,63 +1207,63 @@ public final class LocalTimeProtocol { return getLocationFieldBuilder().addBuilder( index, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance()); } - public java.util.List + public java.util.List getLocationBuilderList() { return getLocationFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.jboss.netty.example.localtime.LocalTimeProtocol.Location, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder> + org.jboss.netty.example.localtime.LocalTimeProtocol.Location, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder> getLocationFieldBuilder() { if (locationBuilder_ == null) { locationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< org.jboss.netty.example.localtime.LocalTimeProtocol.Location, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder>( location_, - ((bitField0_ & 0x00000001) == 0x00000001), + (bitField0_ & 0x00000001) == 0x00000001, getParentForChildren(), isClean()); location_ = null; } return locationBuilder_; } - + // @@protoc_insertion_point(builder_scope:org.jboss.netty.example.localtime.Locations) } - + static { defaultInstance = new Locations(true); defaultInstance.initFields(); } - + // @@protoc_insertion_point(class_scope:org.jboss.netty.example.localtime.Locations) } - + public interface LocalTimeOrBuilder extends com.google.protobuf.MessageOrBuilder { - + // required uint32 year = 1; boolean hasYear(); int getYear(); - + // required uint32 month = 2; boolean hasMonth(); int getMonth(); - + // required uint32 dayOfMonth = 4; boolean hasDayOfMonth(); int getDayOfMonth(); - + // required .org.jboss.netty.example.localtime.DayOfWeek dayOfWeek = 5; boolean hasDayOfWeek(); org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek getDayOfWeek(); - + // required uint32 hour = 6; boolean hasHour(); int getHour(); - + // required uint32 minute = 7; boolean hasMinute(); int getMinute(); - + // required uint32 second = 8; boolean hasSecond(); int getSecond(); @@ -1264,97 +1276,97 @@ public final class LocalTimeProtocol { super(builder); } private LocalTime(boolean noInit) {} - + private static final LocalTime defaultInstance; public static LocalTime getDefaultInstance() { return defaultInstance; } - + public LocalTime getDefaultInstanceForType() { return defaultInstance; } - + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTime_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTime_fieldAccessorTable; } - + private int bitField0_; // required uint32 year = 1; public static final int YEAR_FIELD_NUMBER = 1; private int year_; public boolean hasYear() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return (bitField0_ & 0x00000001) == 0x00000001; } public int getYear() { return year_; } - + // required uint32 month = 2; public static final int MONTH_FIELD_NUMBER = 2; private int month_; public boolean hasMonth() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return (bitField0_ & 0x00000002) == 0x00000002; } public int getMonth() { return month_; } - + // required uint32 dayOfMonth = 4; public static final int DAYOFMONTH_FIELD_NUMBER = 4; private int dayOfMonth_; public boolean hasDayOfMonth() { - return ((bitField0_ & 0x00000004) == 0x00000004); + return (bitField0_ & 0x00000004) == 0x00000004; } public int getDayOfMonth() { return dayOfMonth_; } - + // required .org.jboss.netty.example.localtime.DayOfWeek dayOfWeek = 5; public static final int DAYOFWEEK_FIELD_NUMBER = 5; private org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek dayOfWeek_; public boolean hasDayOfWeek() { - return ((bitField0_ & 0x00000008) == 0x00000008); + return (bitField0_ & 0x00000008) == 0x00000008; } public org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek getDayOfWeek() { return dayOfWeek_; } - + // required uint32 hour = 6; public static final int HOUR_FIELD_NUMBER = 6; private int hour_; public boolean hasHour() { - return ((bitField0_ & 0x00000010) == 0x00000010); + return (bitField0_ & 0x00000010) == 0x00000010; } public int getHour() { return hour_; } - + // required uint32 minute = 7; public static final int MINUTE_FIELD_NUMBER = 7; private int minute_; public boolean hasMinute() { - return ((bitField0_ & 0x00000020) == 0x00000020); + return (bitField0_ & 0x00000020) == 0x00000020; } public int getMinute() { return minute_; } - + // required uint32 second = 8; public static final int SECOND_FIELD_NUMBER = 8; private int second_; public boolean hasSecond() { - return ((bitField0_ & 0x00000040) == 0x00000040); + return (bitField0_ & 0x00000040) == 0x00000040; } public int getSecond() { return second_; } - + private void initFields() { year_ = 0; month_ = 0; @@ -1367,8 +1379,10 @@ public final class LocalTimeProtocol { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - + if (isInitialized != -1) { + return isInitialized == 1; + } + if (!hasYear()) { memoizedIsInitialized = 0; return false; @@ -1400,65 +1414,67 @@ public final class LocalTimeProtocol { memoizedIsInitialized = 1; return true; } - + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { output.writeUInt32(1, year_); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if ((bitField0_ & 0x00000002) == 0x00000002) { output.writeUInt32(2, month_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { + if ((bitField0_ & 0x00000004) == 0x00000004) { output.writeUInt32(4, dayOfMonth_); } - if (((bitField0_ & 0x00000008) == 0x00000008)) { + if ((bitField0_ & 0x00000008) == 0x00000008) { output.writeEnum(5, dayOfWeek_.getNumber()); } - if (((bitField0_ & 0x00000010) == 0x00000010)) { + if ((bitField0_ & 0x00000010) == 0x00000010) { output.writeUInt32(6, hour_); } - if (((bitField0_ & 0x00000020) == 0x00000020)) { + if ((bitField0_ & 0x00000020) == 0x00000020) { output.writeUInt32(7, minute_); } - if (((bitField0_ & 0x00000040) == 0x00000040)) { + if ((bitField0_ & 0x00000040) == 0x00000040) { output.writeUInt32(8, second_); } getUnknownFields().writeTo(output); } - + private int memoizedSerializedSize = -1; public int getSerializedSize() { int size = memoizedSerializedSize; - if (size != -1) return size; - + if (size != -1) { + return size; + } + size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(1, year_); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if ((bitField0_ & 0x00000002) == 0x00000002) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(2, month_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { + if ((bitField0_ & 0x00000004) == 0x00000004) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(4, dayOfMonth_); } - if (((bitField0_ & 0x00000008) == 0x00000008)) { + if ((bitField0_ & 0x00000008) == 0x00000008) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(5, dayOfWeek_.getNumber()); } - if (((bitField0_ & 0x00000010) == 0x00000010)) { + if ((bitField0_ & 0x00000010) == 0x00000010) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(6, hour_); } - if (((bitField0_ & 0x00000020) == 0x00000020)) { + if ((bitField0_ & 0x00000020) == 0x00000020) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(7, minute_); } - if (((bitField0_ & 0x00000040) == 0x00000040)) { + if ((bitField0_ & 0x00000040) == 0x00000040) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(8, second_); } @@ -1466,14 +1482,14 @@ public final class LocalTimeProtocol { memoizedSerializedSize = size; return size; } - + private static final long serialVersionUID = 0L; @java.lang.Override protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { return super.writeReplace(); } - + public static org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { @@ -1540,14 +1556,14 @@ public final class LocalTimeProtocol { return newBuilder().mergeFrom(input, extensionRegistry) .buildParsed(); } - + public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } - + @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { @@ -1561,17 +1577,17 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTime_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTime_fieldAccessorTable; } - + // Construct using org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.newBuilder() private Builder() { maybeForceBuilderInitialization(); } - + private Builder(BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); @@ -1583,39 +1599,39 @@ public final class LocalTimeProtocol { private static Builder create() { return new Builder(); } - + public Builder clear() { super.clear(); year_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; month_ = 0; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = bitField0_ & ~0x00000002; dayOfMonth_ = 0; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = bitField0_ & ~0x00000004; dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = bitField0_ & ~0x00000008; hour_ = 0; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = bitField0_ & ~0x00000010; minute_ = 0; - bitField0_ = (bitField0_ & ~0x00000020); + bitField0_ = bitField0_ & ~0x00000020; second_ = 0; - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = bitField0_ & ~0x00000040; return this; } - + public Builder clone() { return create().mergeFrom(buildPartial()); } - + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDescriptor(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime getDefaultInstanceForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime build() { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime result = buildPartial(); if (!result.isInitialized()) { @@ -1623,7 +1639,7 @@ public final class LocalTimeProtocol { } return result; } - + private org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime buildParsed() throws com.google.protobuf.InvalidProtocolBufferException { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime result = buildPartial(); @@ -1633,36 +1649,36 @@ public final class LocalTimeProtocol { } return result; } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime buildPartial() { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime result = new org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + if ((from_bitField0_ & 0x00000001) == 0x00000001) { to_bitField0_ |= 0x00000001; } result.year_ = year_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + if ((from_bitField0_ & 0x00000002) == 0x00000002) { to_bitField0_ |= 0x00000002; } result.month_ = month_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + if ((from_bitField0_ & 0x00000004) == 0x00000004) { to_bitField0_ |= 0x00000004; } result.dayOfMonth_ = dayOfMonth_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + if ((from_bitField0_ & 0x00000008) == 0x00000008) { to_bitField0_ |= 0x00000008; } result.dayOfWeek_ = dayOfWeek_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + if ((from_bitField0_ & 0x00000010) == 0x00000010) { to_bitField0_ |= 0x00000010; } result.hour_ = hour_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + if ((from_bitField0_ & 0x00000020) == 0x00000020) { to_bitField0_ |= 0x00000020; } result.minute_ = minute_; - if (((from_bitField0_ & 0x00000040) == 0x00000040)) { + if ((from_bitField0_ & 0x00000040) == 0x00000040) { to_bitField0_ |= 0x00000040; } result.second_ = second_; @@ -1670,7 +1686,7 @@ public final class LocalTimeProtocol { onBuilt(); return result; } - + public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime) { return mergeFrom((org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime)other); @@ -1679,9 +1695,11 @@ public final class LocalTimeProtocol { return this; } } - + public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime other) { - if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance()) return this; + if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance()) { + return this; + } if (other.hasYear()) { setYear(other.getYear()); } @@ -1703,60 +1721,60 @@ public final class LocalTimeProtocol { if (other.hasSecond()) { setSecond(other.getSecond()); } - this.mergeUnknownFields(other.getUnknownFields()); + mergeUnknownFields(other.getUnknownFields()); return this; } - + public final boolean isInitialized() { if (!hasYear()) { - + return false; } if (!hasMonth()) { - + return false; } if (!hasDayOfMonth()) { - + return false; } if (!hasDayOfWeek()) { - + return false; } if (!hasHour()) { - + return false; } if (!hasMinute()) { - + return false; } if (!hasSecond()) { - + return false; } return true; } - + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); + getUnknownFields()); while (true) { int tag = input.readTag(); switch (tag) { case 0: - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; } @@ -1806,13 +1824,13 @@ public final class LocalTimeProtocol { } } } - + private int bitField0_; - + // required uint32 year = 1; private int year_ ; public boolean hasYear() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return (bitField0_ & 0x00000001) == 0x00000001; } public int getYear() { return year_; @@ -1824,16 +1842,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearYear() { - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; year_ = 0; onChanged(); return this; } - + // required uint32 month = 2; private int month_ ; public boolean hasMonth() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return (bitField0_ & 0x00000002) == 0x00000002; } public int getMonth() { return month_; @@ -1845,16 +1863,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearMonth() { - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = bitField0_ & ~0x00000002; month_ = 0; onChanged(); return this; } - + // required uint32 dayOfMonth = 4; private int dayOfMonth_ ; public boolean hasDayOfMonth() { - return ((bitField0_ & 0x00000004) == 0x00000004); + return (bitField0_ & 0x00000004) == 0x00000004; } public int getDayOfMonth() { return dayOfMonth_; @@ -1866,16 +1884,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearDayOfMonth() { - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = bitField0_ & ~0x00000004; dayOfMonth_ = 0; onChanged(); return this; } - + // required .org.jboss.netty.example.localtime.DayOfWeek dayOfWeek = 5; private org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY; public boolean hasDayOfWeek() { - return ((bitField0_ & 0x00000008) == 0x00000008); + return (bitField0_ & 0x00000008) == 0x00000008; } public org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek getDayOfWeek() { return dayOfWeek_; @@ -1890,16 +1908,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearDayOfWeek() { - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = bitField0_ & ~0x00000008; dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY; onChanged(); return this; } - + // required uint32 hour = 6; private int hour_ ; public boolean hasHour() { - return ((bitField0_ & 0x00000010) == 0x00000010); + return (bitField0_ & 0x00000010) == 0x00000010; } public int getHour() { return hour_; @@ -1911,16 +1929,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearHour() { - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = bitField0_ & ~0x00000010; hour_ = 0; onChanged(); return this; } - + // required uint32 minute = 7; private int minute_ ; public boolean hasMinute() { - return ((bitField0_ & 0x00000020) == 0x00000020); + return (bitField0_ & 0x00000020) == 0x00000020; } public int getMinute() { return minute_; @@ -1932,16 +1950,16 @@ public final class LocalTimeProtocol { return this; } public Builder clearMinute() { - bitField0_ = (bitField0_ & ~0x00000020); + bitField0_ = bitField0_ & ~0x00000020; minute_ = 0; onChanged(); return this; } - + // required uint32 second = 8; private int second_ ; public boolean hasSecond() { - return ((bitField0_ & 0x00000040) == 0x00000040); + return (bitField0_ & 0x00000040) == 0x00000040; } public int getSecond() { return second_; @@ -1953,32 +1971,32 @@ public final class LocalTimeProtocol { return this; } public Builder clearSecond() { - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = bitField0_ & ~0x00000040; second_ = 0; onChanged(); return this; } - + // @@protoc_insertion_point(builder_scope:org.jboss.netty.example.localtime.LocalTime) } - + static { defaultInstance = new LocalTime(true); defaultInstance.initFields(); } - + // @@protoc_insertion_point(class_scope:org.jboss.netty.example.localtime.LocalTime) } - + public interface LocalTimesOrBuilder extends com.google.protobuf.MessageOrBuilder { - + // repeated .org.jboss.netty.example.localtime.LocalTime localTime = 1; - java.util.List + java.util.List getLocalTimeList(); org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime getLocalTime(int index); int getLocalTimeCount(); - java.util.List + java.util.List getLocalTimeOrBuilderList(); org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder getLocalTimeOrBuilder( int index); @@ -1991,33 +2009,33 @@ public final class LocalTimeProtocol { super(builder); } private LocalTimes(boolean noInit) {} - + private static final LocalTimes defaultInstance; public static LocalTimes getDefaultInstance() { return defaultInstance; } - + public LocalTimes getDefaultInstanceForType() { return defaultInstance; } - + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTimes_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTimes_fieldAccessorTable; } - + // repeated .org.jboss.netty.example.localtime.LocalTime localTime = 1; public static final int LOCALTIME_FIELD_NUMBER = 1; private java.util.List localTime_; public java.util.List getLocalTimeList() { return localTime_; } - public java.util.List + public java.util.List getLocalTimeOrBuilderList() { return localTime_; } @@ -2031,15 +2049,17 @@ public final class LocalTimeProtocol { int index) { return localTime_.get(index); } - + private void initFields() { localTime_ = java.util.Collections.emptyList(); } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - + if (isInitialized != -1) { + return isInitialized == 1; + } + for (int i = 0; i < getLocalTimeCount(); i++) { if (!getLocalTime(i).isInitialized()) { memoizedIsInitialized = 0; @@ -2049,7 +2069,7 @@ public final class LocalTimeProtocol { memoizedIsInitialized = 1; return true; } - + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); @@ -2058,12 +2078,14 @@ public final class LocalTimeProtocol { } getUnknownFields().writeTo(output); } - + private int memoizedSerializedSize = -1; public int getSerializedSize() { int size = memoizedSerializedSize; - if (size != -1) return size; - + if (size != -1) { + return size; + } + size = 0; for (int i = 0; i < localTime_.size(); i++) { size += com.google.protobuf.CodedOutputStream @@ -2073,14 +2095,14 @@ public final class LocalTimeProtocol { memoizedSerializedSize = size; return size; } - + private static final long serialVersionUID = 0L; @java.lang.Override protected java.lang.Object writeReplace() throws java.io.ObjectStreamException { return super.writeReplace(); } - + public static org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { @@ -2147,14 +2169,14 @@ public final class LocalTimeProtocol { return newBuilder().mergeFrom(input, extensionRegistry) .buildParsed(); } - + public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } - + @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { @@ -2168,17 +2190,17 @@ public final class LocalTimeProtocol { getDescriptor() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTimes_descriptor; } - + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.jboss.netty.example.localtime.LocalTimeProtocol.internal_static_org_jboss_netty_example_localtime_LocalTimes_fieldAccessorTable; } - + // Construct using org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.newBuilder() private Builder() { maybeForceBuilderInitialization(); } - + private Builder(BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); @@ -2191,31 +2213,31 @@ public final class LocalTimeProtocol { private static Builder create() { return new Builder(); } - + public Builder clear() { super.clear(); if (localTimeBuilder_ == null) { localTime_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } else { localTimeBuilder_.clear(); } return this; } - + public Builder clone() { return create().mergeFrom(buildPartial()); } - + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDescriptor(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes getDefaultInstanceForType() { return org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDefaultInstance(); } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes build() { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes result = buildPartial(); if (!result.isInitialized()) { @@ -2223,7 +2245,7 @@ public final class LocalTimeProtocol { } return result; } - + private org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes buildParsed() throws com.google.protobuf.InvalidProtocolBufferException { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes result = buildPartial(); @@ -2233,14 +2255,14 @@ public final class LocalTimeProtocol { } return result; } - + public org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes buildPartial() { org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes result = new org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes(this); int from_bitField0_ = bitField0_; if (localTimeBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if ((bitField0_ & 0x00000001) == 0x00000001) { localTime_ = java.util.Collections.unmodifiableList(localTime_); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } result.localTime_ = localTime_; } else { @@ -2249,7 +2271,7 @@ public final class LocalTimeProtocol { onBuilt(); return result; } - + public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes) { return mergeFrom((org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes)other); @@ -2258,14 +2280,16 @@ public final class LocalTimeProtocol { return this; } } - + public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes other) { - if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDefaultInstance()) return this; + if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDefaultInstance()) { + return this; + } if (localTimeBuilder_ == null) { if (!other.localTime_.isEmpty()) { if (localTime_.isEmpty()) { localTime_ = other.localTime_; - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; } else { ensureLocalTimeIsMutable(); localTime_.addAll(other.localTime_); @@ -2278,8 +2302,8 @@ public final class LocalTimeProtocol { localTimeBuilder_.dispose(); localTimeBuilder_ = null; localTime_ = other.localTime_; - bitField0_ = (bitField0_ & ~0x00000001); - localTimeBuilder_ = + bitField0_ = bitField0_ & ~0x00000001; + localTimeBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getLocalTimeFieldBuilder() : null; } else { @@ -2287,38 +2311,38 @@ public final class LocalTimeProtocol { } } } - this.mergeUnknownFields(other.getUnknownFields()); + mergeUnknownFields(other.getUnknownFields()); return this; } - + public final boolean isInitialized() { for (int i = 0; i < getLocalTimeCount(); i++) { if (!getLocalTime(i).isInitialized()) { - + return false; } } return true; } - + public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); + getUnknownFields()); while (true) { int tag = input.readTag(); switch (tag) { case 0: - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); + setUnknownFields(unknownFields.build()); onChanged(); return this; } @@ -2333,9 +2357,9 @@ public final class LocalTimeProtocol { } } } - + private int bitField0_; - + // repeated .org.jboss.netty.example.localtime.LocalTime localTime = 1; private java.util.List localTime_ = java.util.Collections.emptyList(); @@ -2345,10 +2369,10 @@ public final class LocalTimeProtocol { bitField0_ |= 0x00000001; } } - + private com.google.protobuf.RepeatedFieldBuilder< org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder> localTimeBuilder_; - + public java.util.List getLocalTimeList() { if (localTimeBuilder_ == null) { return java.util.Collections.unmodifiableList(localTime_); @@ -2458,7 +2482,7 @@ public final class LocalTimeProtocol { public Builder clearLocalTime() { if (localTimeBuilder_ == null) { localTime_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = bitField0_ & ~0x00000001; onChanged(); } else { localTimeBuilder_.clear(); @@ -2486,7 +2510,7 @@ public final class LocalTimeProtocol { return localTimeBuilder_.getMessageOrBuilder(index); } } - public java.util.List + public java.util.List getLocalTimeOrBuilderList() { if (localTimeBuilder_ != null) { return localTimeBuilder_.getMessageOrBuilderList(); @@ -2503,36 +2527,36 @@ public final class LocalTimeProtocol { return getLocalTimeFieldBuilder().addBuilder( index, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance()); } - public java.util.List + public java.util.List getLocalTimeBuilderList() { return getLocalTimeFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder> + org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder> getLocalTimeFieldBuilder() { if (localTimeBuilder_ == null) { localTimeBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder>( localTime_, - ((bitField0_ & 0x00000001) == 0x00000001), + (bitField0_ & 0x00000001) == 0x00000001, getParentForChildren(), isClean()); localTime_ = null; } return localTimeBuilder_; } - + // @@protoc_insertion_point(builder_scope:org.jboss.netty.example.localtime.LocalTimes) } - + static { defaultInstance = new LocalTimes(true); defaultInstance.initFields(); } - + // @@protoc_insertion_point(class_scope:org.jboss.netty.example.localtime.LocalTimes) } - + private static com.google.protobuf.Descriptors.Descriptor internal_static_org_jboss_netty_example_localtime_Location_descriptor; private static @@ -2553,7 +2577,7 @@ public final class LocalTimeProtocol { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_org_jboss_netty_example_localtime_LocalTimes_fieldAccessorTable; - + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -2628,6 +2652,6 @@ public final class LocalTimeProtocol { new com.google.protobuf.Descriptors.FileDescriptor[] { }, assigner); } - + // @@protoc_insertion_point(outer_class_scope) } diff --git a/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java b/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java index 4f413346bb..3d7a646f8e 100644 --- a/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java +++ b/src/main/java/org/jboss/netty/example/portunification/PortUnificationServer.java @@ -38,7 +38,7 @@ public class PortUnificationServer { public PortUnificationServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxy.java b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxy.java index ecf0f7faaf..3dc47c0373 100644 --- a/src/main/java/org/jboss/netty/example/proxy/HexDumpProxy.java +++ b/src/main/java/org/jboss/netty/example/proxy/HexDumpProxy.java @@ -29,7 +29,7 @@ public class HexDumpProxy { 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; diff --git a/src/main/java/org/jboss/netty/example/securechat/SecureChatClient.java b/src/main/java/org/jboss/netty/example/securechat/SecureChatClient.java index 48a3bdae23..7d5dcbe7ef 100644 --- a/src/main/java/org/jboss/netty/example/securechat/SecureChatClient.java +++ b/src/main/java/org/jboss/netty/example/securechat/SecureChatClient.java @@ -34,7 +34,7 @@ public class SecureChatClient { private final String host; private final int port; - + public SecureChatClient(String host, int port) { this.host = host; this.port = port; diff --git a/src/main/java/org/jboss/netty/example/telnet/TelnetClient.java b/src/main/java/org/jboss/netty/example/telnet/TelnetClient.java index aa04e51657..7532bf70cd 100644 --- a/src/main/java/org/jboss/netty/example/telnet/TelnetClient.java +++ b/src/main/java/org/jboss/netty/example/telnet/TelnetClient.java @@ -33,7 +33,7 @@ public class TelnetClient { private final String host; private final int port; - + public TelnetClient(String host, int port) { this.host = host; this.port = port; diff --git a/src/main/java/org/jboss/netty/example/telnet/TelnetServer.java b/src/main/java/org/jboss/netty/example/telnet/TelnetServer.java index b433a36a48..4a55109f66 100644 --- a/src/main/java/org/jboss/netty/example/telnet/TelnetServer.java +++ b/src/main/java/org/jboss/netty/example/telnet/TelnetServer.java @@ -27,11 +27,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; public class TelnetServer { private final int port; - + public TelnetServer(int port) { this.port = port; } - + public void run() { // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( diff --git a/src/main/java/org/jboss/netty/handler/codec/PrematureChannelClosureException.java b/src/main/java/org/jboss/netty/handler/codec/PrematureChannelClosureException.java index 3e890b0706..c257c7891d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/PrematureChannelClosureException.java +++ b/src/main/java/org/jboss/netty/handler/codec/PrematureChannelClosureException.java @@ -16,33 +16,33 @@ package org.jboss.netty.handler.codec; /** - * Exception which should get thrown if a Channel got closed before it is expected + * Exception which should get thrown if a Channel got closed before it is expected */ public class PrematureChannelClosureException extends Exception { - + /** - * + * */ private static final long serialVersionUID = 233460005724966593L; public PrematureChannelClosureException() { super(); } - + public PrematureChannelClosureException(String msg) { super(msg); } - - + + public PrematureChannelClosureException(String msg, Throwable t) { super(msg, t); } - - + + public PrematureChannelClosureException(Throwable t) { super(t); } - + } diff --git a/src/main/java/org/jboss/netty/handler/codec/base64/Base64Decoder.java b/src/main/java/org/jboss/netty/handler/codec/base64/Base64Decoder.java index de38fe2868..9c452c2a05 100644 --- a/src/main/java/org/jboss/netty/handler/codec/base64/Base64Decoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/base64/Base64Decoder.java @@ -18,9 +18,9 @@ package org.jboss.netty.handler.codec.base64; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.frame.FrameDecoder; diff --git a/src/main/java/org/jboss/netty/handler/codec/base64/Base64Encoder.java b/src/main/java/org/jboss/netty/handler/codec/base64/Base64Encoder.java index 383fed4110..cf14811f72 100644 --- a/src/main/java/org/jboss/netty/handler/codec/base64/Base64Encoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/base64/Base64Encoder.java @@ -17,9 +17,9 @@ package org.jboss.netty.handler.codec.base64; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; diff --git a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java index bd518755ef..6a23308e2d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java @@ -192,7 +192,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne * and the specified preset dictionary. The wrapper is always * {@link ZlibWrapper#ZLIB} because it is the only format that supports * the preset dictionary. - * + * * @param compressionLevel * {@code 1} yields the fastest compression and {@code 9} yields the * best compression. {@code 0} means no compression. The default diff --git a/src/main/java/org/jboss/netty/handler/codec/frame/DelimiterBasedFrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/frame/DelimiterBasedFrameDecoder.java index f9d7912d59..5691e7a55c 100644 --- a/src/main/java/org/jboss/netty/handler/codec/frame/DelimiterBasedFrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/frame/DelimiterBasedFrameDecoder.java @@ -187,7 +187,7 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder { this.stripDelimiter = stripDelimiter; this.failFast = failFast; } - + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { diff --git a/src/main/java/org/jboss/netty/handler/codec/frame/FixedLengthFrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/frame/FixedLengthFrameDecoder.java index 65991fb804..794a17cc32 100644 --- a/src/main/java/org/jboss/netty/handler/codec/frame/FixedLengthFrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/frame/FixedLengthFrameDecoder.java @@ -40,21 +40,21 @@ public class FixedLengthFrameDecoder extends FrameDecoder { private final int frameLength; private final boolean allocateFullBuffer; - + /** * Calls {@link #FixedLengthFrameDecoder(int, boolean)} with false */ public FixedLengthFrameDecoder(int frameLength) { this(frameLength, false); } - + /** * Creates a new instance. * * @param frameLength the length of the frame * @param allocateFullBuffer true if the cumulative {@link ChannelBuffer} should use the {@link #frameLength} as its initial size */ - public FixedLengthFrameDecoder(int frameLength, boolean allocateFullBuffer) { + public FixedLengthFrameDecoder(int frameLength, boolean allocateFullBuffer) { if (frameLength <= 0) { throw new IllegalArgumentException( "frameLength must be a positive integer: " + frameLength); @@ -72,7 +72,7 @@ public class FixedLengthFrameDecoder extends FrameDecoder { return buffer.readBytes(frameLength); } } - + @Override protected ChannelBuffer newCumulationBuffer(ChannelHandlerContext ctx, int minimumCapacity) { ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory(); diff --git a/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java index 20cecaeaed..a95289e687 100644 --- a/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.java @@ -402,14 +402,14 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder { long tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; discardingTooLongFrame = false; - if ((!failFast) || - (failFast && firstDetectionOfTooLongFrame)) { + if (!failFast || + failFast && firstDetectionOfTooLongFrame) { fail(ctx, tooLongFrameLength); } } else { // Keep discarding and notify handlers if necessary. if (failFast && firstDetectionOfTooLongFrame) { - fail(ctx, this.tooLongFrameLength); + fail(ctx, tooLongFrameLength); } } diff --git a/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldPrepender.java b/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldPrepender.java index d3d0debe1d..beb0d13d17 100644 --- a/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldPrepender.java +++ b/src/main/java/org/jboss/netty/handler/codec/frame/LengthFieldPrepender.java @@ -22,8 +22,8 @@ import java.nio.ByteOrder; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferFactory; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; /** diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java index 82b0043bf4..d153aab18b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpClientCodec.java @@ -36,10 +36,10 @@ import org.jboss.netty.util.internal.QueueFactory; * {@link HttpResponseDecoder} to learn what additional state management needs * to be done for HEAD and CONNECT and why * {@link HttpResponseDecoder} can not handle it by itself. - * + * * If the {@link Channel} gets closed and there are requests missing for a response * a {@link PrematureChannelClosureException} is thrown. - * + * * @see HttpServerCodec * * @apiviz.has org.jboss.netty.handler.codec.http.HttpResponseDecoder @@ -64,7 +64,7 @@ public class HttpClientCodec implements ChannelUpstreamHandler, * Creates a new instance with the default decoder options * ({@code maxInitialLineLength (4096}}, {@code maxHeaderSize (8192)}, and * {@code maxChunkSize (8192)}). - * + * */ public HttpClientCodec() { this(4096, 8192, 8192, false); @@ -109,9 +109,9 @@ public class HttpClientCodec implements ChannelUpstreamHandler, if (msg instanceof HttpRequest && !done) { queue.offer(((HttpRequest) msg).getMethod()); } - + Object obj = super.encode(ctx, channel, msg); - + if (failOnMissingResponse) { // check if the request is chunked if so do not increment if (msg instanceof HttpRequest && !((HttpRequest) msg).isChunked()) { @@ -149,7 +149,7 @@ public class HttpClientCodec implements ChannelUpstreamHandler, if (msg == null) { return; } - + // check if its a HttpMessage and its not chunked if (msg instanceof HttpMessage && !((HttpMessage) msg).isChunked()) { requestResponseCounter.decrementAndGet(); @@ -212,7 +212,7 @@ public class HttpClientCodec implements ChannelUpstreamHandler, return super.isContentAlwaysEmpty(msg); } - + @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelClosed(ctx, e); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java index fa71d0ad5d..cb739cf659 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java @@ -37,9 +37,9 @@ public class DefaultHttpDataFactory implements HttpDataFactory { */ public static long MINSIZE = 0x4000; - private boolean useDisk; + private final boolean useDisk; - private boolean checkSize; + private final boolean checkSize; private long minSize; @@ -55,7 +55,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory { public DefaultHttpDataFactory() { useDisk = false; checkSize = true; - this.minSize = MINSIZE; + minSize = MINSIZE; } /** @@ -79,7 +79,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory { } /** - * + * * @param request * @return the associated list of Files for the request */ @@ -91,7 +91,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory { } return list; } - + public Attribute createAttribute(HttpRequest request, String name) { if (useDisk) { Attribute attribute = new DiskAttribute(name); diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpData.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpData.java index 1b80708883..183e751901 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpData.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpData.java @@ -28,7 +28,7 @@ import org.jboss.netty.buffer.ChannelBuffer; public interface HttpData extends InterfaceHttpData { /** * Set the content from the ChannelBuffer (erase any previous data) - * + * * @param buffer * must be not null * @exception IOException @@ -37,7 +37,7 @@ public interface HttpData extends InterfaceHttpData { /** * Add the content from the ChannelBuffer - * + * * @param buffer * must be not null except if last is set to False * @param last @@ -48,7 +48,7 @@ public interface HttpData extends InterfaceHttpData { /** * Set the content from the file (erase any previous data) - * + * * @param file * must be not null * @exception IOException @@ -57,7 +57,7 @@ public interface HttpData extends InterfaceHttpData { /** * Set the content from the inputStream (erase any previous data) - * + * * @param inputStream * must be not null * @exception IOException @@ -65,14 +65,14 @@ public interface HttpData extends InterfaceHttpData { void setContent(InputStream inputStream) throws IOException; /** - * + * * @return True if the InterfaceHttpData is completed (all data are stored) */ boolean isCompleted(); /** * Returns the size in byte of the InterfaceHttpData - * + * * @return the size of the InterfaceHttpData */ long length(); @@ -85,7 +85,7 @@ public interface HttpData extends InterfaceHttpData { /** * Returns the contents of the file item as an array of bytes. - * + * * @return the contents of the file item as an array of bytes. * @exception IOException */ @@ -93,7 +93,7 @@ public interface HttpData extends InterfaceHttpData { /** * Returns the content of the file item as a ChannelBuffer - * + * * @return the content of the file item as a ChannelBuffer * @throws IOException */ @@ -104,7 +104,7 @@ public interface HttpData extends InterfaceHttpData { * most length read bytes, increasing the current position of the Bytes * read. Once it arrives at the end, it returns an EMPTY_BUFFER and it * resets the current position to 0. - * + * * @param length * @return a ChannelBuffer for the content from the current position or an * EMPTY_BUFFER if there is no more data to return @@ -115,7 +115,7 @@ public interface HttpData extends InterfaceHttpData { /** * Returns the contents of the file item as a String, using the default * character encoding. - * + * * @return the contents of the file item as a String, using the default * character encoding. * @exception IOException @@ -125,7 +125,7 @@ public interface HttpData extends InterfaceHttpData { /** * Returns the contents of the file item as a String, using the specified * charset. - * + * * @param encoding * the charset to use * @return the contents of the file item as a String, using the specified @@ -136,7 +136,7 @@ public interface HttpData extends InterfaceHttpData { /** * Set the Charset passed by the browser if defined - * + * * @param charset * Charset to set - must be not null */ @@ -144,7 +144,7 @@ public interface HttpData extends InterfaceHttpData { /** * Returns the Charset passed by the browser or null if not defined. - * + * * @return the Charset passed by the browser or null if not defined. */ Charset getCharset(); @@ -154,7 +154,7 @@ public interface HttpData extends InterfaceHttpData { * exists, it will be deleted. Once this method is called, if successful, * the new file will be out of the cleaner of the factory that creates the * original InterfaceHttpData object. - * + * * @param dest * destination file - must be not null * @return True if the write is successful @@ -165,13 +165,13 @@ public interface HttpData extends InterfaceHttpData { /** * Provides a hint as to whether or not the file contents will be read from * memory. - * + * * @return True if the file contents is in memory. */ boolean isInMemory(); /** - * + * * @return the associated File if this data is represented in a file * @exception IOException * if this data is not represented by a file diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostBodyUtil.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostBodyUtil.java index 5c76e7fbc9..2f8f1c8b0f 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostBodyUtil.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostBodyUtil.java @@ -147,9 +147,9 @@ final class HttpPostBodyUtil { throw new SeekAheadNoBackArrayException(); } this.buffer = buffer; - this.bytes = buffer.array(); - this.pos = this.readerIndex = buffer.readerIndex(); - this.limit = buffer.writerIndex(); + bytes = buffer.array(); + pos = readerIndex = buffer.readerIndex(); + limit = buffer.writerIndex(); } /** @@ -164,11 +164,11 @@ final class HttpPostBodyUtil { } void clear() { - this.buffer = null; - this.bytes = null; - this.limit = 0; - this.pos = 0; - this.readerIndex = 0; + buffer = null; + bytes = null; + limit = 0; + pos = 0; + readerIndex = 0; } } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/BinaryWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/BinaryWebSocketFrame.java index 09241a6a30..175e99b57e 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/BinaryWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/BinaryWebSocketFrame.java @@ -32,7 +32,7 @@ public class BinaryWebSocketFrame extends WebSocketFrame { /** * Creates a new binary frame with the specified binary data. The final fragment flag is set to true. - * + * * @param binaryData * the content of the frame. */ @@ -42,7 +42,7 @@ public class BinaryWebSocketFrame extends WebSocketFrame { /** * Creates a new binary frame with the specified binary data and the final fragment flag. - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java index d92182224e..147cacace0 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java @@ -34,7 +34,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { /** * Creates a new empty close frame with closing status code and reason text - * + * * @param statusCode * Integer status code as per RFC 6455. For * example, 1000 indicates normal closure. @@ -47,7 +47,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { /** * Creates a new close frame with no losing status code and no reason text - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -59,7 +59,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { /** * Creates a new close frame with closing status code and reason text - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -96,7 +96,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { /** * Creates a new close frame - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -119,7 +119,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { * a status code is set, -1 is returned. */ public int getStatusCode() { - ChannelBuffer binaryData = this.getBinaryData(); + ChannelBuffer binaryData = getBinaryData(); if (binaryData == null || binaryData.capacity() == 0) { return -1; } @@ -136,7 +136,7 @@ public class CloseWebSocketFrame extends WebSocketFrame { * text is not supplied, an empty string is returned. */ public String getReasonText() { - ChannelBuffer binaryData = this.getBinaryData(); + ChannelBuffer binaryData = getBinaryData(); if (binaryData == null || binaryData.capacity() <= 2) { return ""; } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java index 05304e9996..f14e7039c0 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/ContinuationWebSocketFrame.java @@ -36,7 +36,7 @@ public class ContinuationWebSocketFrame extends WebSocketFrame { /** * Creates a new continuation frame with the specified binary data. The final fragment flag is set to true. - * + * * @param binaryData * the content of the frame. */ @@ -46,7 +46,7 @@ public class ContinuationWebSocketFrame extends WebSocketFrame { /** * Creates a new continuation frame with the specified binary data - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -62,7 +62,7 @@ public class ContinuationWebSocketFrame extends WebSocketFrame { /** * Creates a new continuation frame with the specified binary data - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -81,7 +81,7 @@ public class ContinuationWebSocketFrame extends WebSocketFrame { /** * Creates a new continuation frame with the specified text data - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -107,7 +107,7 @@ public class ContinuationWebSocketFrame extends WebSocketFrame { /** * Sets the string for this frame - * + * * @param text * text to store */ diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PingWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PingWebSocketFrame.java index 1a54e35dad..febb3bc423 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PingWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PingWebSocketFrame.java @@ -33,7 +33,7 @@ public class PingWebSocketFrame extends WebSocketFrame { /** * Creates a new ping frame with the specified binary data. - * + * * @param binaryData * the content of the frame. */ @@ -43,7 +43,7 @@ public class PingWebSocketFrame extends WebSocketFrame { /** * Creates a new ping frame with the specified binary data - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PongWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PongWebSocketFrame.java index c09f77113c..0ad3093da8 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PongWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/PongWebSocketFrame.java @@ -32,7 +32,7 @@ public class PongWebSocketFrame extends WebSocketFrame { /** * Creates a new pong frame with the specified binary data. - * + * * @param binaryData * the content of the frame. */ @@ -42,7 +42,7 @@ public class PongWebSocketFrame extends WebSocketFrame { /** * Creates a new pong frame with the specified binary data - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/TextWebSocketFrame.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/TextWebSocketFrame.java index c39ce97d66..2225e402c3 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/TextWebSocketFrame.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/TextWebSocketFrame.java @@ -33,7 +33,7 @@ public class TextWebSocketFrame extends WebSocketFrame { /** * Creates a new text frame with the specified text string. The final fragment flag is set to true. - * + * * @param text * String to put in the frame */ @@ -47,7 +47,7 @@ public class TextWebSocketFrame extends WebSocketFrame { /** * Creates a new text frame with the specified binary data. The final fragment flag is set to true. - * + * * @param binaryData * the content of the frame. Must be UTF-8 encoded */ @@ -57,7 +57,7 @@ public class TextWebSocketFrame extends WebSocketFrame { /** * Creates a new text frame with the specified text string. The final fragment flag is set to true. - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -77,7 +77,7 @@ public class TextWebSocketFrame extends WebSocketFrame { /** * Creates a new text frame with the specified binary data. The final fragment flag is set to true. - * + * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv @@ -103,7 +103,7 @@ public class TextWebSocketFrame extends WebSocketFrame { /** * Sets the string for this frame - * + * * @param text * text to store */ diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Exception.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Exception.java index 9a406bb9f3..057983556d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Exception.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Exception.java @@ -18,18 +18,18 @@ * * Copyright (c) 2008-2009 Bjoern Hoehrmann * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions + * The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO - * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.jboss.netty.handler.codec.http.websocketx; diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Output.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Output.java index f853aa32d2..3f923bb080 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Output.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/UTF8Output.java @@ -18,18 +18,18 @@ * * Copyright (c) 2008-2009 Bjoern Hoehrmann * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions + * The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO - * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.jboss.netty.handler.codec.http.websocketx; diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java index ac5d92b934..b67f335fdb 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameDecoder.java @@ -27,7 +27,7 @@ import org.jboss.netty.handler.codec.replay.VoidEnum; *

* For the detailed instruction on adding add Web Socket support to your HTTP server, take a look into the * WebSocketServer example located in the {@code org.jboss.netty.example.http.websocket} package. - * + * * @apiviz.landmark * @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame */ @@ -45,7 +45,7 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder { /** * Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client * sends a frame size larger than {@code maxFrameSize}, the channel will be closed. - * + * * @param maxFrameSize * the maximum frame size to decode * @deprecated @@ -54,11 +54,11 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder { public WebSocket00FrameDecoder(int maxFrameSize) { this.maxFrameSize = maxFrameSize; } - + /** * Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client * sends a frame size larger than {@code maxFrameSize}, the channel will be closed. - * + * * @param maxFrameSize * the maximum frame size to decode */ diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameEncoder.java index ddaf9f81de..d2146b6e85 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket00FrameEncoder.java @@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.http.websocketx; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; /** @@ -26,7 +26,7 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; *

* For the detailed instruction on adding add Web Socket support to your HTTP server, take a look into the * WebSocketServer example located in the {@code org.jboss.netty.example.http.websocket} package. - * + * * @apiviz.landmark * @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame */ diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java index aa13a2cb00..ce8194bde8 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket08FrameEncoder.java @@ -85,7 +85,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder { /** * Constructor - * + * * @param maskPayload * Web socket clients must set this to true to mask payload. Server implementations must set this to * false. diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameDecoder.java index ee38bfb245..27fdf99eef 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameDecoder.java @@ -61,7 +61,7 @@ public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder { /** * Constructor with default values - * + * * @param maskedPayload * Web socket servers must set this to true processed incoming masked payload. Client implementations * must set this to false. @@ -74,7 +74,7 @@ public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder { /** * Constructor - * + * * @param maskedPayload * Web socket servers must set this to true processed incoming * masked payload. Client implementations must set this to false. diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameEncoder.java index 69b620106c..4e5613e073 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocket13FrameEncoder.java @@ -62,7 +62,7 @@ public class WebSocket13FrameEncoder extends WebSocket08FrameEncoder { /** * Constructor - * + * * @param maskPayload * Web socket clients must set this to true to mask payload. Server implementations must set this to * false. diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java index ebf2cc8de6..7d4bf636b5 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java @@ -58,7 +58,7 @@ public abstract class WebSocketClientHandshaker { Map customHeaders) { this(webSocketUrl, version, subprotocol, customHeaders, Long.MAX_VALUE); } - + /** * Base constructor * @@ -78,7 +78,7 @@ public abstract class WebSocketClientHandshaker { Map customHeaders, long maxFramePayloadLength) { this.webSocketUrl = webSocketUrl; this.version = version; - this.expectedSubprotocol = subprotocol; + expectedSubprotocol = subprotocol; this.customHeaders = customHeaders; this.maxFramePayloadLength = maxFramePayloadLength; } @@ -98,12 +98,12 @@ public abstract class WebSocketClientHandshaker { } /** - * Returns the max length for any frame's payload + * Returns the max length for any frame's payload */ public long getMaxFramePayloadLength() { return maxFramePayloadLength; } - + /** * Flag to indicate if the opening handshake is complete */ @@ -136,7 +136,7 @@ public abstract class WebSocketClientHandshaker { /** * Begins the opening handshake - * + * * @param channel * Channel */ @@ -144,7 +144,7 @@ public abstract class WebSocketClientHandshaker { /** * Validates and finishes the opening handshake initiated by {@link #handshake}}. - * + * * @param channel * Channel * @param response diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java index 7318ff2b1d..9afb7f6cc8 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java @@ -53,7 +53,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { /** * Constructor with default values - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -70,10 +70,10 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { boolean allowExtensions, Map customHeaders) { this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); } - + /** * Constructor - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -100,7 +100,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { *

* Sends the opening request to the server: *

- * + * *
      * GET /chat HTTP/1.1
      * Host: server.example.com
@@ -111,7 +111,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
      * Sec-WebSocket-Protocol: chat, superchat
      * Sec-WebSocket-Version: 8
      * 
- * + * * @param channel * Channel into which we can write our request */ @@ -151,16 +151,16 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { // See http://tools.ietf.org/html/rfc6454#section-6.2 originValue = originValue + ":" + wsPort; } - + // Use Sec-WebSocket-Origin // See https://github.com/netty/netty/issues/264 request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue); - - String expectedSubprotocol = this.getExpectedSubprotocol(); + + String expectedSubprotocol = getExpectedSubprotocol(); if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) { request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } - + request.addHeader(Names.SEC_WEBSOCKET_VERSION, "8"); if (customHeaders != null) { @@ -180,7 +180,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { *

* Process server response: *

- * + * *
      * HTTP/1.1 101 Switching Protocols
      * Upgrade: websocket
@@ -188,7 +188,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
      * Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
      * Sec-WebSocket-Protocol: chat
      * 
- * + * * @param channel * Channel * @param response @@ -205,14 +205,14 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { String upgrade = response.getHeader(Names.UPGRADE); // Upgrade header should be matched case-insensitive. - // See https://github.com/netty/netty/issues/278 + // See https://github.com/netty/netty/issues/278 if (upgrade == null || !upgrade.toLowerCase().equals(Values.WEBSOCKET.toLowerCase())) { throw new WebSocketHandshakeException("Invalid handshake response upgrade: " + response.getHeader(Names.UPGRADE)); } // Connection header should be matched case-insensitive. - // See https://github.com/netty/netty/issues/278 + // See https://github.com/netty/netty/issues/278 String connection = response.getHeader(Names.CONNECTION); if (connection == null || !connection.toLowerCase().equals(Values.UPGRADE.toLowerCase())) { throw new WebSocketHandshakeException("Invalid handshake response connection: " @@ -227,13 +227,13 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { String subprotocol = response.getHeader(Names.SEC_WEBSOCKET_PROTOCOL); setActualSubprotocol(subprotocol); - + setHandshakeComplete(); channel.getPipeline().get(HttpResponseDecoder.class).replace("ws-decoder", - new WebSocket08FrameDecoder(false, allowExtensions, this.getMaxFramePayloadLength())); - + new WebSocket08FrameDecoder(false, allowExtensions, getMaxFramePayloadLength())); + } } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java index 2192e2a671..852dbba480 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java @@ -53,7 +53,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { /** * Constructor with default values - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -70,10 +70,10 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { boolean allowExtensions, Map customHeaders) { this(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); } - + /** * Constructor - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -99,7 +99,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { *

* Sends the opening request to the server: *

- * + * *
      * GET /chat HTTP/1.1
      * Host: server.example.com
@@ -110,7 +110,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
      * Sec-WebSocket-Protocol: chat, superchat
      * Sec-WebSocket-Version: 13
      * 
- * + * * @param channel * Channel into which we can write our request */ @@ -152,11 +152,11 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { } request.addHeader(Names.ORIGIN, originValue); - String expectedSubprotocol = this.getExpectedSubprotocol(); + String expectedSubprotocol = getExpectedSubprotocol(); if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) { request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } - + request.addHeader(Names.SEC_WEBSOCKET_VERSION, "13"); if (customHeaders != null) { @@ -164,7 +164,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { request.addHeader(header, customHeaders.get(header)); } } - + ChannelFuture future = channel.write(request); channel.getPipeline().replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket13FrameEncoder(true)); @@ -176,7 +176,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { *

* Process server response: *

- * + * *
      * HTTP/1.1 101 Switching Protocols
      * Upgrade: websocket
@@ -184,7 +184,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
      * Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
      * Sec-WebSocket-Protocol: chat
      * 
- * + * * @param channel * Channel * @param response @@ -201,14 +201,14 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { String upgrade = response.getHeader(Names.UPGRADE); // Upgrade header should be matched case-insensitive. - // See https://github.com/netty/netty/issues/278 + // See https://github.com/netty/netty/issues/278 if (upgrade == null || !upgrade.toLowerCase().equals(Values.WEBSOCKET.toLowerCase())) { throw new WebSocketHandshakeException("Invalid handshake response upgrade: " + response.getHeader(Names.UPGRADE)); } // Connection header should be matched case-insensitive. - // See https://github.com/netty/netty/issues/278 + // See https://github.com/netty/netty/issues/278 String connection = response.getHeader(Names.CONNECTION); if (connection == null || !connection.toLowerCase().equals(Values.UPGRADE.toLowerCase())) { throw new WebSocketHandshakeException("Invalid handshake response connection: " @@ -227,8 +227,8 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { setHandshakeComplete(); channel.getPipeline().get(HttpResponseDecoder.class).replace("ws-decoder", - new WebSocket13FrameDecoder(false, allowExtensions, this.getMaxFramePayloadLength())); - + new WebSocket13FrameDecoder(false, allowExtensions, getMaxFramePayloadLength())); + } } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java index bdb962938b..a9c2b0d8eb 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java @@ -25,7 +25,7 @@ public class WebSocketClientHandshakerFactory { /** * Instances a new handshaker - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -43,10 +43,10 @@ public class WebSocketClientHandshakerFactory { boolean allowExtensions, Map customHeaders) throws WebSocketHandshakeException { return newHandshaker(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); } - + /** * Instances a new handshaker - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -78,5 +78,5 @@ public class WebSocketClientHandshakerFactory { throw new WebSocketHandshakeException("Protocol version " + version.toString() + " not supported."); } - + } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java index a2afd391b1..a9011291c4 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker.java @@ -54,7 +54,7 @@ public abstract class WebSocketServerHandshaker { /** * Constructor using default values - * + * * @param version * the protocol version * @param webSocketUrl @@ -71,7 +71,7 @@ public abstract class WebSocketServerHandshaker { /** * Constructor specifying the destination web socket location - * + * * @param version * the protocol version * @param webSocketUrl @@ -112,7 +112,7 @@ public abstract class WebSocketServerHandshaker { */ public Set getSubprotocols() { Set ret = new LinkedHashSet(); - for (String p : this.subprotocols) { + for (String p : subprotocols) { ret.add(p); } return ret; @@ -134,7 +134,7 @@ public abstract class WebSocketServerHandshaker { /** * Performs the opening handshake - * + * * @param channel * Channel * @param req @@ -144,7 +144,7 @@ public abstract class WebSocketServerHandshaker { /** * Performs the closing handshake - * + * * @param channel * Channel * @param frame @@ -154,7 +154,7 @@ public abstract class WebSocketServerHandshaker { /** * Selects the first matching supported sub protocol - * + * * @param requestedSubprotocols * CSV of protocols to be supported. e.g. "chat, superchat" * @return First matching supported sub protocol. Null if not found. @@ -178,9 +178,9 @@ public abstract class WebSocketServerHandshaker { // No match found return null; } - + /** - * Returns the selected subprotocol. Null if no subprotocol has been selected. + * Returns the selected subprotocol. Null if no subprotocol has been selected. *

* This is only available AFTER handshake() has been called. *

@@ -188,9 +188,9 @@ public abstract class WebSocketServerHandshaker { public String getSelectedSubprotocol() { return selectedSubprotocol; } - + protected void setSelectedSubprotocol(String value) { selectedSubprotocol = value; } - + } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java index 01442c22f5..75c86e235d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker00.java @@ -52,7 +52,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { /** * Constructor with default values - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -62,10 +62,10 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { public WebSocketServerHandshaker00(String webSocketURL, String subprotocols) { this(webSocketURL, subprotocols, Long.MAX_VALUE); } - + /** * Constructor specifying the destination web socket location - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -86,11 +86,11 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { * is really a rehash of hixie-76 and * hixie-75. *

- * + * *

* Browser request to the server: *

- * + * *
      * GET /demo HTTP/1.1
      * Upgrade: WebSocket
@@ -100,14 +100,14 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Protocol: chat, sample
      * Sec-WebSocket-Key1: 4 @1  46546xW%0l 1 5
      * Sec-WebSocket-Key2: 12998 5 Y3 1  .P00
-     * 
+     *
      * ^n:ds[4U
      * 
- * + * *

* Server response: *

- * + * *
      * HTTP/1.1 101 WebSocket Protocol Handshake
      * Upgrade: WebSocket
@@ -115,10 +115,10 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Origin: http://example.com
      * Sec-WebSocket-Location: ws://example.com/demo
      * Sec-WebSocket-Protocol: sample
-     * 
+     *
      * 8jKS'y:G*Co,Wxa-
      * 
- * + * * @param channel * Channel * @param req @@ -158,7 +158,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols); } else { res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol); - this.setSelectedSubprotocol(selectedSubprotocol); + setSelectedSubprotocol(selectedSubprotocol); } } @@ -190,7 +190,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { p.remove(HttpChunkAggregator.class); } p.replace(HttpRequestDecoder.class, "wsdecoder", - new WebSocket00FrameDecoder(this.getMaxFramePayloadLength())); + new WebSocket00FrameDecoder(getMaxFramePayloadLength())); ChannelFuture future = channel.write(res); @@ -201,7 +201,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker { /** * Echo back the closing frame - * + * * @param channel * Channel * @param frame diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java index 2889731628..5592c1f847 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker08.java @@ -54,7 +54,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { /** * Constructor using defaults - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -66,10 +66,10 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions) { this(webSocketURL, subprotocols, allowExtensions, Long.MAX_VALUE); } - + /** * Constructor - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -93,11 +93,11 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { * "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-08">HyBi version 8 to 10. Version 8, 9 and * 10 share the same wire protocol. *

- * + * *

* Browser request to the server: *

- * + * *
      * GET /chat HTTP/1.1
      * Host: server.example.com
@@ -108,11 +108,11 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Protocol: chat, superchat
      * Sec-WebSocket-Version: 8
      * 
- * + * *

* Server response: *

- * + * *
      * HTTP/1.1 101 Switching Protocols
      * Upgrade: websocket
@@ -120,7 +120,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
      * Sec-WebSocket-Protocol: chat
      * 
- * + * * @param channel * Channel * @param req @@ -163,7 +163,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols); } else { res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol); - this.setSelectedSubprotocol(selectedSubprotocol); + setSelectedSubprotocol(selectedSubprotocol); } } @@ -175,8 +175,8 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { p.remove(HttpChunkAggregator.class); } - p.replace(HttpRequestDecoder.class, "wsdecoder", - new WebSocket08FrameDecoder(true, allowExtensions, this.getMaxFramePayloadLength())); + p.replace(HttpRequestDecoder.class, "wsdecoder", + new WebSocket08FrameDecoder(true, allowExtensions, getMaxFramePayloadLength())); p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket08FrameEncoder(false)); return future; @@ -184,7 +184,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { /** * Echo back the closing frame and close the connection - * + * * @param channel * Channel * @param frame diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java index 327f994930..eb5fbbc794 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.java @@ -15,8 +15,8 @@ */ package org.jboss.netty.handler.codec.http.websocketx; -import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.WEBSOCKET; -import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; +import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.*; +import static org.jboss.netty.handler.codec.http.HttpVersion.*; import java.io.UnsupportedEncodingException; @@ -25,14 +25,14 @@ import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.Channels; -import org.jboss.netty.handler.codec.http.HttpChunkAggregator; import org.jboss.netty.handler.codec.http.DefaultHttpResponse; +import org.jboss.netty.handler.codec.http.HttpChunkAggregator; +import org.jboss.netty.handler.codec.http.HttpHeaders.Names; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpRequestDecoder; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseEncoder; import org.jboss.netty.handler.codec.http.HttpResponseStatus; -import org.jboss.netty.handler.codec.http.HttpHeaders.Names; import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.util.CharsetUtil; @@ -56,7 +56,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { /** * Constructor using defaults - * + * * @param webSocketURL * URL for web socket communications. e.g * "ws://myhost.com/mypath". Subsequent web socket frames will be @@ -73,7 +73,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { /** * Constructor specifying the destination web socket location - * + * * @param webSocketURL * URL for web socket communications. e.g * "ws://myhost.com/mypath". Subsequent web socket frames will be @@ -100,11 +100,11 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { * "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17">HyBi * versions 13-17. Versions 13-17 share the same wire protocol. *

- * + * *

* Browser request to the server: *

- * + * *
      * GET /chat HTTP/1.1
      * Host: server.example.com
@@ -115,11 +115,11 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Protocol: chat, superchat
      * Sec-WebSocket-Version: 13
      * 
- * + * *

* Server response: *

- * + * *
      * HTTP/1.1 101 Switching Protocols
      * Upgrade: websocket
@@ -127,7 +127,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
      * Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
      * Sec-WebSocket-Protocol: chat
      * 
- * + * * @param channel * Channel * @param req @@ -170,7 +170,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols); } else { res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol); - this.setSelectedSubprotocol(selectedSubprotocol); + setSelectedSubprotocol(selectedSubprotocol); } } @@ -183,7 +183,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { } p.replace(HttpRequestDecoder.class, "wsdecoder", - new WebSocket13FrameDecoder(true, allowExtensions, this.getMaxFramePayloadLength())); + new WebSocket13FrameDecoder(true, allowExtensions, getMaxFramePayloadLength())); p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket13FrameEncoder(false)); return future; @@ -191,7 +191,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { /** * Echo back the closing frame and close the connection - * + * * @param channel * Channel * @param frame diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java index 6cc107185f..d3c7beb27b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java @@ -17,11 +17,11 @@ package org.jboss.netty.handler.codec.http.websocketx; import org.jboss.netty.channel.Channel; import org.jboss.netty.handler.codec.http.DefaultHttpResponse; +import org.jboss.netty.handler.codec.http.HttpHeaders.Names; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; -import org.jboss.netty.handler.codec.http.HttpHeaders.Names; /** * Instances the appropriate handshake class to use for servers @@ -35,10 +35,10 @@ public class WebSocketServerHandshakerFactory { private final boolean allowExtensions; private final long maxFramePayloadLength; - + /** * Constructor - + * @param subprotocols * CSV of supported protocols. Null if sub protocols not supported. * @param allowExtensions @@ -50,7 +50,7 @@ public class WebSocketServerHandshakerFactory { /** * Constructor - * + * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be * sent to this URL. @@ -62,17 +62,17 @@ public class WebSocketServerHandshakerFactory { * Maximum allowable frame payload length. Setting this value to your application's requirement may * reduce denial of service attacks using long data frames. */ - public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, + public WebSocketServerHandshakerFactory(String webSocketURL, String subprotocols, boolean allowExtensions, long maxFramePayloadLength) { this.webSocketURL = webSocketURL; this.subprotocols = subprotocols; this.allowExtensions = allowExtensions; this.maxFramePayloadLength = maxFramePayloadLength; } - + /** * Instances a new handshaker - * + * * @return A new WebSocketServerHandshaker for the requested web socket version. Null if web socket version is not * supported. */ @@ -97,7 +97,7 @@ public class WebSocketServerHandshakerFactory { /** * Return that we need cannot not support the web socket version - * + * * @param channel * Channel */ diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/package-info.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/package-info.java index 7e9a45628b..d64c1295f9 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/package-info.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/package-info.java @@ -30,8 +30,8 @@ * For the detailed instruction on adding add Web Socket support to your HTTP * server, take a look into the WebSocketServerX example located in the * {@code org.jboss.netty.example.http.websocket} package. - *

- * + *

+ * * @apiviz.exclude OneToOne(Encoder|Decoder)$ * @apiviz.exclude \.codec\.replay\. * @apiviz.exclude \.Default diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteInput.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteInput.java index 5ea086bb78..6a59684a8b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteInput.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteInput.java @@ -22,7 +22,7 @@ import org.jboss.netty.buffer.ChannelBuffer; /** * {@link ByteInput} implementation which reads its data from a {@link ChannelBuffer} - * + * * */ class ChannelBufferByteInput implements ByteInput { @@ -32,7 +32,7 @@ class ChannelBufferByteInput implements ByteInput { public ChannelBufferByteInput(ChannelBuffer buffer) { this.buffer = buffer; } - + public void close() throws IOException { // nothing to do } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteOutput.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteOutput.java index de95ad3f33..b0c2661bc9 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteOutput.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/ChannelBufferByteOutput.java @@ -24,28 +24,28 @@ import org.jboss.netty.buffer.ChannelBuffers; /** * {@link ByteOutput} implementation which writes the data to a {@link ChannelBuffer} - * + * * */ class ChannelBufferByteOutput implements ByteOutput { - + private final ChannelBuffer buffer; - + /** * Create a new instance which use the given {@link ChannelBuffer} */ public ChannelBufferByteOutput(ChannelBuffer buffer) { this.buffer = buffer; } - + /** - * Calls {@link #ChannelBufferByteOutput(ChannelBuffer)} with a dynamic {@link ChannelBuffer} + * Calls {@link #ChannelBufferByteOutput(ChannelBuffer)} with a dynamic {@link ChannelBuffer} */ public ChannelBufferByteOutput(ChannelBufferFactory factory, int estimatedLength) { this(ChannelBuffers.dynamicBuffer(estimatedLength, factory)); } - + public void close() throws IOException { // Nothing todo } @@ -65,10 +65,10 @@ class ChannelBufferByteOutput implements ByteOutput { public void write(byte[] bytes, int srcIndex, int length) throws IOException { buffer.writeBytes(bytes, srcIndex, length); } - + /** * Return the {@link ChannelBuffer} which contains the written content - * + * */ public ChannelBuffer getBuffer() { return buffer; diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java index 76fdae0b24..5d8beef14f 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java @@ -29,38 +29,38 @@ import org.jboss.netty.handler.codec.replay.VoidEnum; /** * {@link ReplayingDecoder} which use an {@link Unmarshaller} to read the Object out of the {@link ChannelBuffer}. - * + * * If you can you should use {@link MarshallingDecoder}. - * - * + * + * * */ public class CompatibleMarshallingDecoder extends ReplayingDecoder { protected final UnmarshallerProvider provider; protected final int maxObjectSize; - + /** - * Create a new instance of {@link CompatibleMarshallingDecoder}. - * + * Create a new instance of {@link CompatibleMarshallingDecoder}. + * * @param provider the {@link UnmarshallerProvider} which is used to obtain the {@link Unmarshaller} for the {@link Channel} * @param maxObjectSize the maximal size (in bytes) of the {@link Object} to unmarshal. Once the size is exceeded - * the {@link Channel} will get closed. Use a a maxObjectSize of {@link Integer#MAX_VALUE} to disable this. + * the {@link Channel} will get closed. Use a a maxObjectSize of {@link Integer#MAX_VALUE} to disable this. * You should only do this if you are sure that the received Objects will never be big and the * sending side are trusted, as this opens the possibility for a DOS-Attack due an {@link OutOfMemoryError}. - * + * */ public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize) { this.provider = provider; this.maxObjectSize = maxObjectSize; } - + @Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { Unmarshaller unmarshaller = provider.getUnmarshaller(ctx); ByteInput input = new ChannelBufferByteInput(buffer); if (maxObjectSize != Integer.MAX_VALUE) { input = new LimitingByteInput(input, maxObjectSize); - } + } try { unmarshaller.start(input); Object obj = unmarshaller.readObject(); diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingEncoder.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingEncoder.java index 3403eb2a59..430782dbe2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/CompatibleMarshallingEncoder.java @@ -17,17 +17,17 @@ package org.jboss.netty.handler.codec.marshalling; import org.jboss.marshalling.Marshaller; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; /** - * {@link OneToOneEncoder} implementation which uses JBoss Marshalling to marshal + * {@link OneToOneEncoder} implementation which uses JBoss Marshalling to marshal * an Object. - * - * See JBoss Marshalling website + * + * See JBoss Marshalling website * for more informations - * + * * Use {@link MarshallingEncoder} if possible. * */ @@ -39,14 +39,14 @@ public class CompatibleMarshallingEncoder extends OneToOneEncoder { /** * Create a new instance of the {@link CompatibleMarshallingEncoder} - * + * * @param provider the {@link MarshallerProvider} to use to get the {@link Marshaller} for a {@link Channel} */ public CompatibleMarshallingEncoder(MarshallerProvider provider) { this.provider = provider; } - - + + @Override protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { Marshaller marshaller = provider.getMarshaller(ctx); @@ -55,7 +55,7 @@ public class CompatibleMarshallingEncoder extends OneToOneEncoder { marshaller.writeObject(msg); marshaller.finish(); marshaller.close(); - + return output.getBuffer(); } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/ContextBoundUnmarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/ContextBoundUnmarshallerProvider.java index dee1ae2c83..68d97521db 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/ContextBoundUnmarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/ContextBoundUnmarshallerProvider.java @@ -23,11 +23,11 @@ import org.jboss.netty.channel.ChannelHandler; import org.jboss.netty.channel.ChannelHandlerContext; /** - * {@link UnmarshallerProvider} which store a reference to the {@link Unmarshaller} in the - * {@link ChannelHandlerContext} via the {@link ChannelHandlerContext#setAttachment(Object)} + * {@link UnmarshallerProvider} which store a reference to the {@link Unmarshaller} in the + * {@link ChannelHandlerContext} via the {@link ChannelHandlerContext#setAttachment(Object)} * method. So the same {@link Unmarshaller} will be used during the life-time of a {@link Channel} * for the {@link ChannelHandler}'s {@link ChannelHandlerContext}. - * + * * */ public class ContextBoundUnmarshallerProvider extends DefaultUnmarshallerProvider { diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultMarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultMarshallerProvider.java index dd2c953875..a66bf7dc28 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultMarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultMarshallerProvider.java @@ -23,17 +23,17 @@ import org.jboss.netty.channel.ChannelHandlerContext; /** * Default implementation of {@link MarshallerProvider} which just create a new {@link Marshaller} * on ever {@link #getMarshaller(ChannelHandlerContext)} call. - * + * * */ public class DefaultMarshallerProvider implements MarshallerProvider { private final MarshallerFactory factory; private final MarshallingConfiguration config; - + /** - * Create a new instance - * + * Create a new instance + * * @param factory the {@link MarshallerFactory} to use to create {@link Marshaller} * @param config the {@link MarshallingConfiguration} */ @@ -41,7 +41,7 @@ public class DefaultMarshallerProvider implements MarshallerProvider { this.factory = factory; this.config = config; } - + public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception { return factory.createMarshaller(config); } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultUnmarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultUnmarshallerProvider.java index 441831b90b..a3a0afc491 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultUnmarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/DefaultUnmarshallerProvider.java @@ -29,10 +29,10 @@ public class DefaultUnmarshallerProvider implements UnmarshallerProvider { private final MarshallerFactory factory; private final MarshallingConfiguration config; - + /** - * Create a new instance of {@link DefaultMarshallerProvider} - * + * Create a new instance of {@link DefaultMarshallerProvider} + * * @param factory the {@link MarshallerFactory} to use to create {@link Unmarshaller} * @param config the {@link MarshallingConfiguration} */ @@ -40,7 +40,7 @@ public class DefaultUnmarshallerProvider implements UnmarshallerProvider { this.factory = factory; this.config = config; } - + public Unmarshaller getUnmarshaller(ChannelHandlerContext ctx) throws Exception { return factory.createUnmarshaller(config); } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/LimitingByteInput.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/LimitingByteInput.java index 5076943ecf..70b1b66ab4 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/LimitingByteInput.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/LimitingByteInput.java @@ -22,14 +22,14 @@ import org.jboss.marshalling.ByteInput; /** * {@link ByteInput} implementation which wraps another {@link ByteInput} and throws a {@link TooBigObjectException} * if the read limit was reached. - * + * * */ class LimitingByteInput implements ByteInput { - + // Use a static instance here to remove the overhead of fillStacktrace private static final TooBigObjectException EXCEPTION = new TooBigObjectException(); - + private final ByteInput input; private final long limit; private long read; @@ -41,7 +41,7 @@ class LimitingByteInput implements ByteInput { this.input = input; this.limit = limit; } - + public void close() throws IOException { // Nothing todo } @@ -92,7 +92,7 @@ class LimitingByteInput implements ByteInput { private int readable(int length) { return (int) Math.min(length, limit - read); } - + /** * Exception that will get thrown if the {@link Object} is to big to unmarshall * @@ -100,9 +100,9 @@ class LimitingByteInput implements ByteInput { static final class TooBigObjectException extends IOException { /** - * + * */ private static final long serialVersionUID = 1L; - + } } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallerProvider.java index 83b0dfed66..ae8ff6660e 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallerProvider.java @@ -19,8 +19,8 @@ import org.jboss.marshalling.Marshaller; import org.jboss.netty.channel.ChannelHandlerContext; /** - * This provider is responsible to get a {@link Marshaller} for the given {@link ChannelHandlerContext}. - * + * This provider is responsible to get a {@link Marshaller} for the given {@link ChannelHandlerContext}. + * * */ public interface MarshallerProvider { diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingDecoder.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingDecoder.java index d14faf3343..e826788825 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingDecoder.java @@ -26,7 +26,7 @@ import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.TooLongFrameException; /** * Decoder which MUST be used with {@link MarshallingEncoder}. - * + * * A {@link LengthFieldBasedFrameDecoder} which use an {@link Unmarshaller} to read the Object out of the {@link ChannelBuffer}. * */ @@ -39,12 +39,12 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder { * bytes. If the size of the received object is greater than * {@code 1048576} bytes, a {@link StreamCorruptedException} will be * raised. - * + * */ public MarshallingDecoder(UnmarshallerProvider provider) { this(provider, 1048576); } - + /** * Creates a new decoder with the specified maximum object size. * @@ -57,8 +57,8 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder { super(maxObjectSize, 0, 4, 0, 4); this.provider = provider; } - - + + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { @@ -70,7 +70,7 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder { Unmarshaller unmarshaller = provider.getUnmarshaller(ctx); ByteInput input = new ChannelBufferByteInput(frame); - + try { unmarshaller.start(input); Object obj = unmarshaller.readObject(); diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingEncoder.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingEncoder.java index c82e54d8c3..e8bd2013b9 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/MarshallingEncoder.java @@ -18,19 +18,19 @@ package org.jboss.netty.handler.codec.marshalling; import org.jboss.marshalling.Marshaller; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; /** - * {@link OneToOneEncoder} implementation which uses JBoss Marshalling to marshal - * an Object. Be aware that this {@link OneToOneEncoder} is not compatible with - * an other client that just use JBoss Marshalling as it includes the size of every + * {@link OneToOneEncoder} implementation which uses JBoss Marshalling to marshal + * an Object. Be aware that this {@link OneToOneEncoder} is not compatible with + * an other client that just use JBoss Marshalling as it includes the size of every * {@link Object} that gets serialized in front of the {@link Object} itself. - * + * * Use this with {@link MarshallingDecoder} - * - * See JBoss Marshalling website + * + * See JBoss Marshalling website * for more informations * */ @@ -43,7 +43,7 @@ public class MarshallingEncoder extends OneToOneEncoder { /** * Creates a new encoder with the estimated length of 512 bytes. - * + * * @param provider the {@link MarshallerProvider} to use */ public MarshallingEncoder(MarshallerProvider provider) { @@ -54,7 +54,7 @@ public class MarshallingEncoder extends OneToOneEncoder { * Creates a new encoder. * * @param provider - * the {@link MarshallerProvider} to use + * the {@link MarshallerProvider} to use * @param estimatedLength * the estimated byte length of the serialized form of an object. * If the length of the serialized form exceeds this value, the @@ -81,11 +81,11 @@ public class MarshallingEncoder extends OneToOneEncoder { marshaller.writeObject(msg); marshaller.finish(); marshaller.close(); - - + + ChannelBuffer encoded = output.getBuffer(); encoded.setInt(0, encoded.writerIndex() - 4); - + return encoded; } diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java index 9fb3f865f6..48f2a7a00c 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalMarshallerProvider.java @@ -24,9 +24,9 @@ import org.jboss.netty.channel.ChannelHandlerContext; * {@link UnmarshallerProvider} implementation which use a {@link ThreadLocal} to store references * to {@link Marshaller} instances. This may give you some performance boost if you need to marshall * many small {@link Object}'s and your actual Thread count is not to big - * - * - * + * + * + * * */ public class ThreadLocalMarshallerProvider implements MarshallerProvider { @@ -34,10 +34,10 @@ public class ThreadLocalMarshallerProvider implements MarshallerProvider { private final MarshallerFactory factory; private final MarshallingConfiguration config; - + /** * Create a new instance of the {@link ThreadLocalMarshallerProvider} - * + * * @param factory the {@link MarshallerFactory} to use to create {@link Marshaller}'s if needed * @param config the {@link MarshallingConfiguration} to use */ diff --git a/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java b/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java index c23d56c53d..7d6db75056 100644 --- a/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java +++ b/src/main/java/org/jboss/netty/handler/codec/marshalling/ThreadLocalUnmarshallerProvider.java @@ -24,7 +24,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; * {@link UnmarshallerProvider} implementation which use a {@link ThreadLocal} to store references * to {@link Unmarshaller} instances. This may give you some performance boost if you need to unmarshall * many small {@link Object}'s. - * + * * */ public class ThreadLocalUnmarshallerProvider implements UnmarshallerProvider { @@ -32,10 +32,10 @@ public class ThreadLocalUnmarshallerProvider implements UnmarshallerProvider { private final MarshallerFactory factory; private final MarshallingConfiguration config; - + /** * Create a new instance of the {@link ThreadLocalUnmarshallerProvider} - * + * * @param factory the {@link MarshallerFactory} to use to create {@link Unmarshaller}'s if needed * @param config the {@link MarshallingConfiguration} to use */ @@ -52,5 +52,5 @@ public class ThreadLocalUnmarshallerProvider implements UnmarshallerProvider { } return unmarshaller; } - + } diff --git a/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufEncoder.java b/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufEncoder.java index 21c38b3a76..93d4985da6 100644 --- a/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufEncoder.java @@ -19,10 +19,10 @@ import static org.jboss.netty.buffer.ChannelBuffers.*; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.LengthFieldPrepender; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; diff --git a/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java b/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java index b8e12a5686..547f502084 100644 --- a/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java +++ b/src/main/java/org/jboss/netty/handler/codec/protobuf/ProtobufVarint32LengthFieldPrepender.java @@ -20,8 +20,8 @@ import static org.jboss.netty.buffer.ChannelBuffers.*; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferOutputStream; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; import com.google.protobuf.CodedOutputStream; diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java index ee0b0261e5..4486723a07 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java @@ -289,7 +289,7 @@ public abstract class ReplayingDecoder> private T state; private int checkpoint; private boolean needsCleanup; - + /** * Creates a new instance with no initial state (i.e: {@code null}). @@ -389,14 +389,14 @@ public abstract class ReplayingDecoder> } /** - * Calls {@link #decode(ChannelHandlerContext, Channel, ChannelBuffer, Enum)}. This method should be never used by {@link ReplayingDecoder} itself. + * Calls {@link #decode(ChannelHandlerContext, Channel, ChannelBuffer, Enum)}. This method should be never used by {@link ReplayingDecoder} itself. * But to be safe we should handle it anyway */ @Override protected final Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { return decode(ctx, channel, buffer, state); } - + @Override protected final Object decodeLast( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { @@ -419,16 +419,16 @@ public abstract class ReplayingDecoder> } needsCleanup = true; - + if (cumulation == null) { // the cumulation buffer is not created yet so just pass the input // to callDecode(...) method - this.cumulation = input; + cumulation = input; replayable = new ReplayingDecoderBuffer(input); int oldReaderIndex = input.readerIndex(); int inputSize = input.readableBytes(); - + // Wrap in try / finally. // // See https://github.com/netty/netty/issues/364 @@ -461,15 +461,15 @@ public abstract class ReplayingDecoder> } replayable = new ReplayingDecoderBuffer(cumulation); } else { - this.cumulation = null; + cumulation = null; replayable = ReplayingDecoderBuffer.EMPTY_BUFFER; } } - + } else { assert cumulation.readable(); boolean fit = false; - + int readable = input.readableBytes(); int writable = cumulation.writableBytes(); int w = writable - readable; @@ -485,16 +485,16 @@ public abstract class ReplayingDecoder> // ok the input fit into the cumulation buffer fit = true; } - + ChannelBuffer buf; if (fit) { // the input fit in the cumulation buffer so copy it over - buf = this.cumulation; + buf = cumulation; buf.writeBytes(input); } else { - // wrap the cumulation and input + // wrap the cumulation and input buf = ChannelBuffers.wrappedBuffer(cumulation, input); - this.cumulation = buf; + cumulation = buf; replayable = new ReplayingDecoderBuffer(cumulation); } @@ -506,17 +506,17 @@ public abstract class ReplayingDecoder> } finally { if (!buf.readable()) { // nothing readable left so reset the state - this.cumulation = null; + cumulation = null; replayable = ReplayingDecoderBuffer.EMPTY_BUFFER; } else { // create a new buffer and copy the readable buffer into it - this.cumulation = newCumulationBuffer(ctx, buf.readableBytes()); - this.cumulation.writeBytes(buf); - replayable = new ReplayingDecoderBuffer(this.cumulation); + cumulation = newCumulationBuffer(ctx, buf.readableBytes()); + cumulation.writeBytes(buf); + replayable = new ReplayingDecoderBuffer(cumulation); } } - + } } @@ -599,5 +599,5 @@ public abstract class ReplayingDecoder> ctx.sendUpstream(e); } } - + } diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/UnsafeDynamicChannelBuffer.java b/src/main/java/org/jboss/netty/handler/codec/replay/UnsafeDynamicChannelBuffer.java index 3454d7fb2f..b3bf089868 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/UnsafeDynamicChannelBuffer.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/UnsafeDynamicChannelBuffer.java @@ -20,9 +20,9 @@ import org.jboss.netty.buffer.DynamicChannelBuffer; /** * This class is not used by {@link ReplayingDecoder} anymore but is still here to not break API. - * + * * This class will get removed in the future. - * + * * @deprecated * */ @@ -37,7 +37,7 @@ class UnsafeDynamicChannelBuffer extends DynamicChannelBuffer { this(factory, 256); } - + @Override protected void checkReadableBytes(int minReaderRemaining) { // Do not check here - ReplayingDecoderBuffer will check. diff --git a/src/main/java/org/jboss/netty/handler/codec/rtsp/RtspMessageEncoder.java b/src/main/java/org/jboss/netty/handler/codec/rtsp/RtspMessageEncoder.java index 93a3eee915..1666144eee 100644 --- a/src/main/java/org/jboss/netty/handler/codec/rtsp/RtspMessageEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/rtsp/RtspMessageEncoder.java @@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.rtsp; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.http.HttpMessage; import org.jboss.netty.handler.codec.http.HttpMessageEncoder; diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java index 200d280e65..7afb9fc0ee 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java @@ -40,7 +40,7 @@ public final class ClassResolvers { public static ClassResolver weakCachingResolver(ClassLoader classLoader) { return new CachingClassResolver(new ClassLoaderClassResolver(defaultClassLoader(classLoader)), new WeakReferenceMap>(new HashMap>>())); } - + /** * agressive non-concurrent cache * good for non-shared cache, when we're not worried about class unloading diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectInputStream.java b/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectInputStream.java index 4cf413538f..c6a761606b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectInputStream.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/CompactObjectInputStream.java @@ -23,7 +23,7 @@ import java.io.ObjectStreamClass; import java.io.StreamCorruptedException; class CompactObjectInputStream extends ObjectInputStream { - + private final ClassResolver classResolver; CompactObjectInputStream(InputStream in, ClassResolver classResolver) throws IOException { diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoder.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoder.java index eef6f056db..03bcd50444 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoder.java @@ -45,7 +45,7 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder { * bytes. If the size of the received object is greater than * {@code 1048576} bytes, a {@link StreamCorruptedException} will be * raised. - * + * * @deprecated use {@link #ObjectDecoder(ClassResolver)} */ @Deprecated @@ -59,13 +59,13 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder { * bytes. If the size of the received object is greater than * {@code 1048576} bytes, a {@link StreamCorruptedException} will be * raised. - * + * * @param classResolver the {@link ClassResolver} to use for this decoder */ public ObjectDecoder(ClassResolver classResolver) { this(1048576, classResolver); } - + /** * Creates a new decoder with the specified maximum object size. * @@ -110,7 +110,7 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder { public ObjectDecoder(int maxObjectSize, ClassLoader classLoader) { this(maxObjectSize, ClassResolvers.weakCachingResolver(classLoader)); } - + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java index 8405ddbed1..a621f09229 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectDecoderInputStream.java @@ -98,7 +98,7 @@ public class ObjectDecoderInputStream extends InputStream implements } else { this.in = new DataInputStream(in); } - this.classResolver = ClassResolvers.weakCachingResolver(classLoader); + classResolver = ClassResolvers.weakCachingResolver(classLoader); this.maxObjectSize = maxObjectSize; } diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoder.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoder.java index 46f60c2099..41eaad26c6 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ObjectEncoder.java @@ -23,8 +23,8 @@ import java.io.ObjectOutputStream; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferOutputStream; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandler.Sharable; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; /** diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java index 7161a3cf8c..369178b3f2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.Set; abstract class ReferenceMap implements Map { - + private final Map> delegate; protected ReferenceMap(Map> delegate) { diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/DefaultSpdyHeaderBlock.java b/src/main/java/org/jboss/netty/handler/codec/spdy/DefaultSpdyHeaderBlock.java index 1f613d8dac..a8b7fe919a 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/DefaultSpdyHeaderBlock.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/DefaultSpdyHeaderBlock.java @@ -40,7 +40,7 @@ public class DefaultSpdyHeaderBlock implements SpdyHeaderBlock { } public void setInvalid() { - this.invalid = true; + invalid = true; } public void addHeader(final String name, final Object value) { diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameDecoder.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameDecoder.java index 676d69b4bb..6fd4b6df3f 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameDecoder.java @@ -410,7 +410,7 @@ public class SpdyFrameDecoder extends FrameDecoder { return new DefaultSpdyPingFrame(ID); case SPDY_GOAWAY_FRAME: - int minLength = (version < 3) ? 4 : 8; + int minLength = version < 3 ? 4 : 8; if (buffer.readableBytes() < minLength) { return null; } @@ -448,7 +448,7 @@ public class SpdyFrameDecoder extends FrameDecoder { int streamID; switch (type) { case SPDY_SYN_STREAM_FRAME: - minLength = (version < 3) ? 12 : 10; + minLength = version < 3 ? 12 : 10; if (buffer.readableBytes() < minLength) { return null; } @@ -477,7 +477,7 @@ public class SpdyFrameDecoder extends FrameDecoder { return spdySynStreamFrame; case SPDY_SYN_REPLY_FRAME: - minLength = (version < 3) ? 8 : 4; + minLength = version < 3 ? 8 : 4; if (buffer.readableBytes() < minLength) { return null; } @@ -575,7 +575,7 @@ public class SpdyFrameDecoder extends FrameDecoder { return; } - int lengthFieldSize = (version < 3) ? 2 : 4; + int lengthFieldSize = version < 3 ? 2 : 4; if (numHeaders == -1) { // Read number of Name/Value pairs @@ -690,10 +690,10 @@ public class SpdyFrameDecoder extends FrameDecoder { private boolean isValidControlFrameHeader() { switch (type) { case SPDY_SYN_STREAM_FRAME: - return (version < 3) ? length >= 12 : length >= 10; + return version < 3 ? length >= 12 : length >= 10; case SPDY_SYN_REPLY_FRAME: - return (version < 3) ? length >= 8 : length >= 4; + return version < 3 ? length >= 8 : length >= 4; case SPDY_RST_STREAM_FRAME: return flags == 0 && length == 8; @@ -708,7 +708,7 @@ public class SpdyFrameDecoder extends FrameDecoder { return length == 4; case SPDY_GOAWAY_FRAME: - return (version < 3) ? length == 4 : length == 8; + return version < 3 ? length == 4 : length == 8; case SPDY_HEADERS_FRAME: if (version < 3) { diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameEncoder.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameEncoder.java index 1d9c965828..6c16cb51f2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyFrameEncoder.java @@ -128,7 +128,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder { int headerBlockLength = data.readableBytes(); int length; if (version < 3) { - length = (headerBlockLength == 0) ? 12 : 10 + headerBlockLength; + length = headerBlockLength == 0 ? 12 : 10 + headerBlockLength; } else { length = 10 + headerBlockLength; } @@ -164,7 +164,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder { int headerBlockLength = data.readableBytes(); int length; if (version < 3) { - length = (headerBlockLength == 0) ? 8 : 6 + headerBlockLength; + length = headerBlockLength == 0 ? 8 : 6 + headerBlockLength; } else { length = 4 + headerBlockLength; } @@ -259,7 +259,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder { } else if (msg instanceof SpdyGoAwayFrame) { SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg; - int length = (version < 3) ? 4 : 8; + int length = version < 3 ? 4 : 8; ChannelBuffer frame = ChannelBuffers.buffer( ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length); frame.writeShort(version | 0x8000); @@ -280,7 +280,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder { int headerBlockLength = data.readableBytes(); int length; if (version < 3) { - length = (headerBlockLength == 0) ? 4 : 6 + headerBlockLength; + length = headerBlockLength == 0 ? 4 : 6 + headerBlockLength; } else { length = 4 + headerBlockLength; } diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java index d85e142fc5..0fbf4d08d4 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibCompressor.java @@ -15,12 +15,12 @@ */ package org.jboss.netty.handler.codec.spdy; +import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*; + import java.util.zip.Deflater; import org.jboss.netty.buffer.ChannelBuffer; -import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*; - class SpdyHeaderBlockZlibCompressor extends SpdyHeaderBlockCompressor { private final byte[] out = new byte[8192]; diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java index 1f154eb606..92203f29df 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecompressor.java @@ -15,13 +15,13 @@ */ package org.jboss.netty.handler.codec.spdy; +import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*; + import java.util.zip.DataFormatException; import java.util.zip.Inflater; import org.jboss.netty.buffer.ChannelBuffer; -import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*; - class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor { private final int version; diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySession.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySession.java index b0a8fbe84b..5ed91e7770 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySession.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySession.java @@ -128,12 +128,12 @@ final class SpdySession { public int getSendWindowSize(int streamID) { StreamState state = activeStreams.get(new Integer(streamID)); - return (state != null) ? state.getSendWindowSize() : -1; + return state != null ? state.getSendWindowSize() : -1; } public int updateSendWindowSize(int streamID, int deltaWindowSize) { StreamState state = activeStreams.get(new Integer(streamID)); - return (state != null) ? state.updateSendWindowSize(deltaWindowSize) : -1; + return state != null ? state.updateSendWindowSize(deltaWindowSize) : -1; } public int updateReceiveWindowSize(int streamID, int deltaWindowSize) { @@ -141,12 +141,12 @@ final class SpdySession { if (deltaWindowSize > 0) { state.setReceiveWindowSizeLowerBound(0); } - return (state != null) ? state.updateReceiveWindowSize(deltaWindowSize) : -1; + return state != null ? state.updateReceiveWindowSize(deltaWindowSize) : -1; } public int getReceiveWindowSizeLowerBound(int streamID) { StreamState state = activeStreams.get(new Integer(streamID)); - return (state != null) ? state.getReceiveWindowSizeLowerBound() : 0; + return state != null ? state.getReceiveWindowSizeLowerBound() : 0; } public void updateAllReceiveWindowSizes(int deltaWindowSize) { @@ -165,12 +165,12 @@ final class SpdySession { public MessageEvent getPendingWrite(int streamID) { StreamState state = activeStreams.get(new Integer(streamID)); - return (state != null) ? state.getPendingWrite() : null; + return state != null ? state.getPendingWrite() : null; } public MessageEvent removePendingWrite(int streamID) { StreamState state = activeStreams.get(new Integer(streamID)); - return (state != null) ? state.removePendingWrite() : null; + return state != null ? state.removePendingWrite() : null; } private static final class StreamState { @@ -179,10 +179,10 @@ final class SpdySession { private volatile boolean remoteSideClosed; private volatile boolean localSideClosed; private boolean receivedReply; - private AtomicInteger sendWindowSize; - private AtomicInteger receiveWindowSize; + private final AtomicInteger sendWindowSize; + private final AtomicInteger receiveWindowSize; private volatile int receiveWindowSizeLowerBound; - private ConcurrentLinkedQueue pendingWriteQueue = + private final ConcurrentLinkedQueue pendingWriteQueue = new ConcurrentLinkedQueue(); public StreamState( diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySessionHandler.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySessionHandler.java index 1f0bbb8bdb..256252d372 100644 --- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySessionHandler.java +++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdySessionHandler.java @@ -93,7 +93,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler "unsupported version: " + version); } this.server = server; - this.flowControl = version >= 3; + flowControl = version >= 3; } @Override diff --git a/src/main/java/org/jboss/netty/handler/codec/string/StringDecoder.java b/src/main/java/org/jboss/netty/handler/codec/string/StringDecoder.java index f893d78a3b..7085bb0dca 100644 --- a/src/main/java/org/jboss/netty/handler/codec/string/StringDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/string/StringDecoder.java @@ -19,10 +19,10 @@ import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.frame.FrameDecoder; diff --git a/src/main/java/org/jboss/netty/handler/codec/string/StringEncoder.java b/src/main/java/org/jboss/netty/handler/codec/string/StringEncoder.java index ccb4b9e35e..1a1890bd6d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/string/StringEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/string/StringEncoder.java @@ -21,10 +21,10 @@ import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.ChannelHandler.Sharable; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; diff --git a/src/main/java/org/jboss/netty/handler/execution/ChainedExecutor.java b/src/main/java/org/jboss/netty/handler/execution/ChainedExecutor.java index 4c1880e817..5429b1d33a 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ChainedExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/ChainedExecutor.java @@ -30,11 +30,11 @@ public class ChainedExecutor implements Executor, ExternalResourceReleasable { private final Executor cur; private final Executor next; private final ChannelEventRunnableFilter filter; - + /** * Create a new {@link ChainedExecutor} which will used the given {@link ChannelEventRunnableFilter} to see if the {@link #cur} {@link Executor} should get used. - * Otherwise it will pass the work to the {@link #next} {@link Executor} - * + * Otherwise it will pass the work to the {@link #next} {@link Executor} + * * @param filter the {@link ChannelEventRunnableFilter} which will be used to check if the {@link ChannelEventRunnable} should be passed to the cur or next {@link Executor} * @param cur the {@link Executor} to use if the {@link ChannelEventRunnableFilter} match * @param next the {@link Executor} to use if the {@link ChannelEventRunnableFilter} does not match @@ -54,9 +54,9 @@ public class ChainedExecutor implements Executor, ExternalResourceReleasable { this.cur = cur; this.next = next; } - + /** - * Execute the passed {@link ChannelEventRunnable} with the current {@link Executor} if the {@link ChannelEventRunnableFilter} match. + * Execute the passed {@link ChannelEventRunnable} with the current {@link Executor} if the {@link ChannelEventRunnableFilter} match. * Otherwise pass it to the next {@link Executor} in the chain. */ public void execute(Runnable command) { @@ -74,7 +74,7 @@ public class ChainedExecutor implements Executor, ExternalResourceReleasable { releaseExternal(next); } - + private static void releaseExternal(Executor executor) { if (executor instanceof ExternalResourceReleasable) { ((ExternalResourceReleasable) executor).releaseExternalResources(); diff --git a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java index 5f3a2e4fdb..0ae4c74867 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java +++ b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java @@ -20,7 +20,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.util.EstimatableObjectWrapper; public abstract class ChannelEventRunnable implements Runnable, EstimatableObjectWrapper { - + protected final ChannelHandlerContext ctx; protected final ChannelEvent e; int estimatedSize; diff --git a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnableFilter.java b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnableFilter.java index bdce153e3a..e3dbc3620c 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnableFilter.java +++ b/src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnableFilter.java @@ -18,10 +18,10 @@ package org.jboss.netty.handler.execution; import java.util.concurrent.Executor; public interface ChannelEventRunnableFilter { - + /** * Return true if the {@link ChannelEventRunnable} should get handled by the {@link Executor} - * + * */ boolean filter(ChannelEventRunnable event); } diff --git a/src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java b/src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java index 2ad4772ff3..c2625d543f 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java +++ b/src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java @@ -36,7 +36,7 @@ public class ChannelUpstreamEventRunnable extends ChannelEventRunnable { super(ctx, e); } - + /** * Sends the event upstream. */ diff --git a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java index 3427f6169f..8bc22635d9 100644 --- a/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java +++ b/src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java @@ -111,7 +111,7 @@ public class ExecutionHandler implements ChannelUpstreamHandler, ChannelDownstre private final Executor executor; private final boolean handleDownstream; private final boolean handleUpstream; - + /** * Creates a new instance with the specified {@link Executor}. * Specify an {@link OrderedMemoryAwareThreadPoolExecutor} if unsure. @@ -120,17 +120,17 @@ public class ExecutionHandler implements ChannelUpstreamHandler, ChannelDownstre this(executor, false, true); } - + /** * Use {@link #ExecutionHandler(Executor, boolean, boolean)} - * + * * {@link Deprecated} */ @Deprecated public ExecutionHandler(Executor executor, boolean handleDownstream) { this(executor, handleDownstream, true); } - + /** * Creates a new instance with the specified {@link Executor}. * Specify an {@link OrderedMemoryAwareThreadPoolExecutor} if unsure. diff --git a/src/main/java/org/jboss/netty/handler/execution/OrderedDownstreamThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/OrderedDownstreamThreadPoolExecutor.java index 9b462f67e0..ec9f6543b8 100644 --- a/src/main/java/org/jboss/netty/handler/execution/OrderedDownstreamThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/OrderedDownstreamThreadPoolExecutor.java @@ -15,29 +15,29 @@ */ package org.jboss.netty.handler.execution; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelEvent; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.ChannelFutureListener; -import org.jboss.netty.util.ObjectSizeEstimator; - import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelEvent; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.util.ObjectSizeEstimator; + /** * {@link Executor} which should be used for downstream {@link ChannelEvent}'s. This implementation will take care of preserve the order of the events in a {@link Channel}. * If you don't need to preserve the order just use one of the {@link Executor} implementations provided by the static methods of {@link Executors}. *
*
- * + * * For more informations about how the order is preserved see {@link OrderedMemoryAwareThreadPoolExecutor} * */ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwareThreadPoolExecutor { - + /** * Creates a new instance. * @@ -73,7 +73,7 @@ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwar keepAliveTime, unit, threadFactory); } - + /** * Return null */ @@ -129,17 +129,17 @@ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwar protected boolean shouldCount(Runnable task) { return false; } - + @Override public void execute(Runnable command) { - + // check if the Runnable was of an unsupported type if (command instanceof ChannelUpstreamEventRunnable) { throw new RejectedExecutionException("command must be enclosed with an downstream event."); } doExecute(command); } - + @Override protected Executor getChildExecutor(ChannelEvent e) { final Object key = getChildExecutorKey(e); @@ -150,10 +150,10 @@ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwar if (oldExecutor != null) { executor = oldExecutor; } else { - + // register a listener so that the ChildExecutor will get removed once the channel was closed e.getChannel().getCloseFuture().addListener(new ChannelFutureListener() { - + public void operationComplete(ChannelFuture future) throws Exception { removeChildExecutor(key); } @@ -164,5 +164,5 @@ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwar return executor; } - + } diff --git a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java index 7b186ef459..04f82a4781 100644 --- a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java @@ -282,11 +282,11 @@ public class OrderedMemoryAwareThreadPoolExecutor extends protected final class ChildExecutor implements Executor, Runnable { private final Queue tasks = QueueFactory.createQueue(Runnable.class); private final AtomicBoolean isRunning = new AtomicBoolean(); - + public void execute(Runnable command) { // TODO: What todo if the add return false ? tasks.add(command); - + if (!isRunning.get()) { doUnorderedExecute(this); @@ -308,7 +308,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends if (task == null) { break; } - + boolean ran = false; beforeExecute(thread, task); try { @@ -326,7 +326,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends // set it back to not running isRunning.set(false); } - + if (acquired && !isRunning.get() && tasks.peek() != null) { doUnorderedExecute(this); } diff --git a/src/main/java/org/jboss/netty/handler/ipfilter/CIDR.java b/src/main/java/org/jboss/netty/handler/ipfilter/CIDR.java index f0e881369f..70979ecbee 100644 --- a/src/main/java/org/jboss/netty/handler/ipfilter/CIDR.java +++ b/src/main/java/org/jboss/netty/handler/ipfilter/CIDR.java @@ -141,9 +141,9 @@ public abstract class CIDR implements Comparable { if (!(arg0 instanceof CIDR)) { return false; } - return this.compareTo((CIDR) arg0) == 0; + return compareTo((CIDR) arg0) == 0; } - + @Override public int hashCode() { return baseAddress.hashCode(); diff --git a/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java b/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java index 2c248fcdb8..ed0b9d4ade 100644 --- a/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java +++ b/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java @@ -95,7 +95,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler, } } - + public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception { if (e instanceof ChannelStateEvent) { ChannelStateEvent evt = (ChannelStateEvent) e; @@ -150,14 +150,14 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler, ctx.sendUpstream(e); } - + public void setIpFilterListener(IpFilterListener listener) { this.listener = listener; } - + public void removeIpFilterListener() { - this.listener = null; + listener = null; } diff --git a/src/main/java/org/jboss/netty/handler/ipfilter/IpSubnet.java b/src/main/java/org/jboss/netty/handler/ipfilter/IpSubnet.java index a35c70d0be..6130b33dee 100644 --- a/src/main/java/org/jboss/netty/handler/ipfilter/IpSubnet.java +++ b/src/main/java/org/jboss/netty/handler/ipfilter/IpSubnet.java @@ -15,11 +15,12 @@ */ package org.jboss.netty.handler.ipfilter; -import org.jboss.netty.logging.InternalLogger; -import org.jboss.netty.logging.InternalLoggerFactory; import java.net.InetAddress; import java.net.UnknownHostException; +import org.jboss.netty.logging.InternalLogger; +import org.jboss.netty.logging.InternalLoggerFactory; + /** * This class allows to check if an IP V4 or V6 Address is contained in a subnet.
*

@@ -54,12 +55,12 @@ import java.net.UnknownHostException; * where inetAddress2 is 1fff:0:0a88:85a3:0:0:ac1f:8001
*/ public class IpSubnet implements IpSet, Comparable { - + private static final InternalLogger logger = InternalLoggerFactory.getInstance(IpSubnet.class); - + /** Internal representation */ - private CIDR cidr; + private final CIDR cidr; /** Create IpSubnet for ALL (used for ALLOW or DENY ALL) */ public IpSubnet() { diff --git a/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java b/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java index d5d4489389..972a7e8145 100644 --- a/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java +++ b/src/main/java/org/jboss/netty/handler/queue/BufferedWriteHandler.java @@ -362,37 +362,37 @@ public class BufferedWriteHandler extends SimpleChannelHandler implements LifeCy Throwable cause = null; for (;;) { MessageEvent ev = queue.poll(); - + if (ev == null) { break; } - + if (cause == null) { cause = new ClosedChannelException(); } ev.getFuture().setFailure(cause); - + } if (cause != null) { Channels.fireExceptionCaught(ctx.getChannel(), cause); } - + super.channelClosed(ctx, e); } public void beforeAdd(ChannelHandlerContext ctx) throws Exception { // Nothing to do - + } public void afterAdd(ChannelHandlerContext ctx) throws Exception { // Nothing to do - + } public void beforeRemove(ChannelHandlerContext ctx) throws Exception { // flush a last time before remove the handler - flush(consolidateOnFlush); + flush(consolidateOnFlush); } /** @@ -402,21 +402,21 @@ public class BufferedWriteHandler extends SimpleChannelHandler implements LifeCy Throwable cause = null; for (;;) { MessageEvent ev = queue.poll(); - + if (ev == null) { break; } - + if (cause == null) { cause = new IOException("Unable to flush message"); } ev.getFuture().setFailure(cause); - + } if (cause != null) { Channels.fireExceptionCaughtLater(ctx.getChannel(), cause); } } - - + + } diff --git a/src/main/java/org/jboss/netty/handler/ssl/SslBufferPool.java b/src/main/java/org/jboss/netty/handler/ssl/SslBufferPool.java index 05ba7b96a2..298e71b3ce 100644 --- a/src/main/java/org/jboss/netty/handler/ssl/SslBufferPool.java +++ b/src/main/java/org/jboss/netty/handler/ssl/SslBufferPool.java @@ -91,15 +91,15 @@ public class SslBufferPool { /** * Acquire a new {@link ByteBuffer} out of the {@link SslBufferPool} - * + * */ public ByteBuffer acquireBuffer() { return acquire(); } - + /** * Will get removed. Please use {@link #acquireBuffer()} - * + * */ @Deprecated synchronized ByteBuffer acquire() { @@ -109,11 +109,11 @@ public class SslBufferPool { return (ByteBuffer) pool[-- index].clear(); } } - + /** * Release a previous acquired {@link ByteBuffer} - * + * * @param buffer */ public void releaseBuffer(ByteBuffer buffer) { @@ -122,9 +122,9 @@ public class SslBufferPool { /** * Will get removed. Please use {@link #releaseBuffer(ByteBuffer)} - * + * * @deprecated - * + * */ @Deprecated synchronized void release(ByteBuffer buffer) { diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java index 9a38492aef..b11caad308 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java @@ -143,21 +143,21 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns private void discard(ChannelHandlerContext ctx, boolean fireNow) { ClosedChannelException cause = null; - + for (;;) { MessageEvent currentEvent = this.currentEvent; - - if (this.currentEvent == null) { - currentEvent = queue.poll(); + + if (this.currentEvent == null) { + currentEvent = queue.poll(); } else { - this.currentEvent = null; + this.currentEvent = null; } - if (currentEvent == null) { - break; + if (currentEvent == null) { + break; } - - + + Object m = currentEvent.getMessage(); if (m instanceof ChunkedInput) { closeInput((ChunkedInput) m); @@ -171,7 +171,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns currentEvent = null; } - + if (cause != null) { if (fireNow) { @@ -189,7 +189,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns // use CAS to see if the have flush already running, if so we don't need to take futher actions if (acquired = flush.compareAndSet(false, true)) { try { - + if (!channel.isConnected()) { discard(ctx, fireNow); return; @@ -251,12 +251,12 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns this.currentEvent = null; writeFuture = currentEvent.getFuture(); - // Register a listener which will close the input once the write is complete. This is needed because the Chunk may have + // Register a listener which will close the input once the write is complete. This is needed because the Chunk may have // some resource bound that can not be closed before its not written // // See https://github.com/netty/netty/issues/303 writeFuture.addListener(new ChannelFutureListener() { - + public void operationComplete(ChannelFuture future) throws Exception { closeInput(chunks); } @@ -292,10 +292,10 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns // mark the flush as done flush.set(false); } - + } - - if (acquired && (!channel.isConnected() || (channel.isWritable() && !queue.isEmpty()))) { + + if (acquired && (!channel.isConnected() || channel.isWritable() && !queue.isEmpty())) { flush(ctx, fireNow); } } @@ -312,12 +312,12 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns public void beforeAdd(ChannelHandlerContext ctx) throws Exception { // nothing to do - + } public void afterAdd(ChannelHandlerContext ctx) throws Exception { // nothing to do - + } public void beforeRemove(ChannelHandlerContext ctx) throws Exception { @@ -329,7 +329,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns // This method should not need any synchronization as the ChunkedWriteHandler will not receive any new events public void afterRemove(ChannelHandlerContext ctx) throws Exception { - // Fail all MessageEvent's that are left. This is needed because otherwise we would never notify the + // Fail all MessageEvent's that are left. This is needed because otherwise we would never notify the // ChannelFuture and the registered FutureListener. See #304 // Throwable cause = null; diff --git a/src/main/java/org/jboss/netty/handler/traffic/TrafficCounter.java b/src/main/java/org/jboss/netty/handler/traffic/TrafficCounter.java index 28dc413f3f..38bd621239 100644 --- a/src/main/java/org/jboss/netty/handler/traffic/TrafficCounter.java +++ b/src/main/java/org/jboss/netty/handler/traffic/TrafficCounter.java @@ -155,8 +155,8 @@ public class TrafficCounter { if (trafficShapingHandler1 != null) { trafficShapingHandler1.doAccounting(counter); } - timeout = - counter.timer.newTimeout(this, counter.checkInterval.get(), TimeUnit.MILLISECONDS); + timeout = + counter.timer.newTimeout(this, counter.checkInterval.get(), TimeUnit.MILLISECONDS); } } @@ -172,7 +172,7 @@ public class TrafficCounter { if (checkInterval.get() > 0) { monitorActive.set(true); timerTask = new TrafficMonitoringTask(trafficShapingHandler, this); - timeout = + timeout = timer.newTimeout(timerTask, checkInterval.get(), TimeUnit.MILLISECONDS); } } @@ -245,7 +245,7 @@ public class TrafficCounter { * @param newcheckInterval */ public void configure(long newcheckInterval) { - long newInterval = (newcheckInterval / 10) * 10; + long newInterval = newcheckInterval / 10 * 10; if (checkInterval.get() != newInterval) { checkInterval.set(newInterval); if (newInterval <= 0) { diff --git a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java index fcafb9c7d5..8b146e2814 100644 --- a/src/main/java/org/jboss/netty/util/HashedWheelTimer.java +++ b/src/main/java/org/jboss/netty/util/HashedWheelTimer.java @@ -454,9 +454,9 @@ public class HashedWheelTimer implements Timer { // // See https://github.com/netty/netty/issues/356 if (DetectionUtil.isWindows()) { - sleepTime = (sleepTime / 10) * 10; + sleepTime = sleepTime / 10 * 10; } - + if (sleepTime <= 0) { break; } @@ -505,7 +505,7 @@ public class HashedWheelTimer implements Timer { // TODO return false return; } - + wheel[stopIndex].remove(this); } diff --git a/src/main/java/org/jboss/netty/util/internal/DetectionUtil.java b/src/main/java/org/jboss/netty/util/internal/DetectionUtil.java index f7d98ec1f0..2ee16b9578 100644 --- a/src/main/java/org/jboss/netty/util/internal/DetectionUtil.java +++ b/src/main/java/org/jboss/netty/util/internal/DetectionUtil.java @@ -26,9 +26,9 @@ import java.util.zip.Deflater; * Utility that detects various properties specific to the current runtime * environment, such as Java version and the availability of the * {@code sun.misc.Unsafe} object. - * + * *
- * You can disable the use of {@code sun.misc.Unsafe} if you specify + * You can disable the use of {@code sun.misc.Unsafe} if you specify * the System property org.jboss.netty.tryUnsafe with * value of false. Default is true. */ @@ -42,15 +42,15 @@ public final class DetectionUtil { // windows IS_WINDOWS = os.indexOf("win") >= 0; } - + /** * Return true if the JVM is running on Windows - * + * */ public static boolean isWindows() { return IS_WINDOWS; } - + public static boolean hasUnsafe() { return HAS_UNSAFE; } @@ -64,7 +64,7 @@ public final class DetectionUtil { if (!useUnsafe) { return false; } - + try { Class unsafeClazz = Class.forName("sun.misc.Unsafe", true, loader); return hasUnsafeField(unsafeClazz); @@ -93,7 +93,7 @@ public final class DetectionUtil { } catch (ClassNotFoundException e) { //Ignore } - + try { Deflater.class.getDeclaredField("SYNC_FLUSH"); return 7; @@ -110,7 +110,7 @@ public final class DetectionUtil { return 5; } - + private DetectionUtil() { // only static method supported } diff --git a/src/main/java/org/jboss/netty/util/internal/QueueFactory.java b/src/main/java/org/jboss/netty/util/internal/QueueFactory.java index 0d6ee6437c..4d3116d6a4 100644 --- a/src/main/java/org/jboss/netty/util/internal/QueueFactory.java +++ b/src/main/java/org/jboss/netty/util/internal/QueueFactory.java @@ -26,18 +26,18 @@ import org.jboss.netty.logging.InternalLoggerFactory; * instance for the running JVM. */ public final class QueueFactory { - + private static final boolean useUnsafe = DetectionUtil.hasUnsafe(); private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(QueueFactory.class); - + private QueueFactory() { // only use static methods! } - - + + /** - * Create a new unbound {@link BlockingQueue} - * + * Create a new unbound {@link BlockingQueue} + * * @param itemClass the {@link Class} type which will be used as {@link BlockingQueue} items * @return queue the {@link BlockingQueue} implementation */ @@ -47,7 +47,7 @@ public final class QueueFactory { if (DetectionUtil.javaVersion() >= 7) { return new java.util.concurrent.LinkedTransferQueue(); } - + try { if (useUnsafe) { return new LinkedTransferQueue(); @@ -61,14 +61,14 @@ public final class QueueFactory { LOGGER.debug("Unable to instance LinkedTransferQueue, fallback to LegacyLinkedTransferQueue", t); } } - + return new LegacyLinkedTransferQueue(); - + } - + /** - * Create a new unbound {@link BlockingQueue} - * + * Create a new unbound {@link BlockingQueue} + * * @param collection the collection which should get copied to the newly created {@link BlockingQueue} * @param itemClass the {@link Class} type which will be used as {@link BlockingQueue} items * @return queue the {@link BlockingQueue} implementation @@ -79,7 +79,7 @@ public final class QueueFactory { if (DetectionUtil.javaVersion() >= 7) { return new java.util.concurrent.LinkedTransferQueue(); } - + try { if (useUnsafe) { return new LinkedTransferQueue(collection); @@ -91,10 +91,10 @@ public final class QueueFactory { // com.sun.Unmisc class. So just log it and fallback to the old LegacyLinkedTransferQueue that works in all cases if (LOGGER.isDebugEnabled()) { LOGGER.debug("Unable to instance LinkedTransferQueue, fallback to LegacyLinkedTransferQueue", t); - } + } } - + return new LegacyLinkedTransferQueue(collection); - + } } diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/Adler32.java b/src/main/java/org/jboss/netty/util/internal/jzlib/Adler32.java index 34628e5eef..91a1a032b1 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/Adler32.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/Adler32.java @@ -113,7 +113,7 @@ final class Adler32 { } return s2 << 16 | s1; } - + private Adler32() { // Utility class } diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/CRC32.java b/src/main/java/org/jboss/netty/util/internal/jzlib/CRC32.java index 7e7f3c65f8..6ccd4b6020 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/CRC32.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/CRC32.java @@ -92,7 +92,7 @@ final class CRC32 { crc32 ^= 0xffffffff; return crc32; } - + private CRC32() { // Utility class } diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/JZlib.java b/src/main/java/org/jboss/netty/util/internal/jzlib/JZlib.java index a87972e127..e036211cfc 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/JZlib.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/JZlib.java @@ -105,7 +105,7 @@ public final class JZlib { static enum WrapperType { NONE, ZLIB, GZIP, ZLIB_OR_NONE; } - + private JZlib() { // Utility class } diff --git a/src/test/java/org/jboss/netty/bootstrap/BootstrapTest.java b/src/test/java/org/jboss/netty/bootstrap/BootstrapTest.java index cf46ee5bfc..dfd500efec 100644 --- a/src/test/java/org/jboss/netty/bootstrap/BootstrapTest.java +++ b/src/test/java/org/jboss/netty/bootstrap/BootstrapTest.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Map.Entry; +import java.util.NoSuchElementException; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelHandler; diff --git a/src/test/java/org/jboss/netty/buffer/AbstractChannelBufferTest.java b/src/test/java/org/jboss/netty/buffer/AbstractChannelBufferTest.java index d6f7812e8a..173b2d19db 100644 --- a/src/test/java/org/jboss/netty/buffer/AbstractChannelBufferTest.java +++ b/src/test/java/org/jboss/netty/buffer/AbstractChannelBufferTest.java @@ -1704,7 +1704,7 @@ public abstract class AbstractChannelBufferTest { assertFalse(set.contains(elemB)); assertEquals(0, set.size()); } - + // Test case for https://github.com/netty/netty/issues/325 @Test public void testDiscardAllReadBytes() { diff --git a/src/test/java/org/jboss/netty/channel/local/LocalAddressTest.java b/src/test/java/org/jboss/netty/channel/local/LocalAddressTest.java index 5f0a35529d..c001a0f6d9 100644 --- a/src/test/java/org/jboss/netty/channel/local/LocalAddressTest.java +++ b/src/test/java/org/jboss/netty/channel/local/LocalAddressTest.java @@ -15,21 +15,17 @@ */ package org.jboss.netty.channel.local; -import org.junit.Assert; -import org.junit.Test; - import org.jboss.netty.bootstrap.ClientBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; -import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ChannelEvent; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; -import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory; -import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory; -import org.jboss.netty.channel.local.LocalAddress; +import org.junit.Assert; +import org.junit.Test; public class LocalAddressTest { private static String LOCAL_ADDR_ID = "test.id"; @@ -67,7 +63,7 @@ public class LocalAddressTest { // Start server sb.bind(addr); - + // Connect to the server ChannelFuture connectFuture = cb.connect(addr); connectFuture.awaitUninterruptibly(); @@ -80,7 +76,7 @@ public class LocalAddressTest { // Wait until the connection is closed, or the connection attempt fails connectFuture.getChannel().getCloseFuture().awaitUninterruptibly(); - + sb.releaseExternalResources(); cb.releaseExternalResources(); diff --git a/src/test/java/org/jboss/netty/channel/local/LocalClientTest.java b/src/test/java/org/jboss/netty/channel/local/LocalClientTest.java index 31cd210cd3..b2e69c43e0 100644 --- a/src/test/java/org/jboss/netty/channel/local/LocalClientTest.java +++ b/src/test/java/org/jboss/netty/channel/local/LocalClientTest.java @@ -15,8 +15,7 @@ */ package org.jboss.netty.channel.local; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.concurrent.CountDownLatch; @@ -37,34 +36,34 @@ public class LocalClientTest { @Test public void testLocalAddressBind() throws InterruptedException { ServerBootstrap sb = new ServerBootstrap(new DefaultLocalServerChannelFactory()); - + LocalAddress addr = new LocalAddress("Server"); LocalAddress addr2 = new LocalAddress("C1"); sb.bind(addr); - - + + ClientBootstrap cb = new ClientBootstrap(new DefaultLocalClientChannelFactory()); final ExceptionHandler handler = new ExceptionHandler(); cb.setPipelineFactory(new ChannelPipelineFactory() { - + public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(handler); } }); ChannelFuture cf = cb.connect(addr, addr2).awaitUninterruptibly(); - + assertTrue(cf.isSuccess()); assertTrue(cf.getChannel().close().awaitUninterruptibly().isSuccess()); - + assertNull(handler.await()); sb.releaseExternalResources(); cb.releaseExternalResources(); } - + final class ExceptionHandler extends SimpleChannelUpstreamHandler { private final CountDownLatch latch = new CountDownLatch(1); private Throwable t; - + @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { super.exceptionCaught(ctx, e); @@ -76,12 +75,12 @@ public class LocalClientTest { super.channelClosed(ctx, e); latch.countDown(); } - + public Throwable await() throws InterruptedException { latch.await(); return t; - + } - + } } diff --git a/src/test/java/org/jboss/netty/channel/socket/AbstractDatagramTest.java b/src/test/java/org/jboss/netty/channel/socket/AbstractDatagramTest.java index 41c75461bd..1b3480da39 100644 --- a/src/test/java/org/jboss/netty/channel/socket/AbstractDatagramTest.java +++ b/src/test/java/org/jboss/netty/channel/socket/AbstractDatagramTest.java @@ -15,16 +15,7 @@ */ package org.jboss.netty.channel.socket; -import static org.junit.Assert.assertTrue; -import org.jboss.netty.bootstrap.ConnectionlessBootstrap; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelHandlerContext; -import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.SimpleChannelUpstreamHandler; -import org.jboss.netty.channel.socket.DatagramChannelFactory; -import org.jboss.netty.util.internal.ExecutorUtil; +import static org.junit.Assert.*; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; @@ -33,6 +24,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.jboss.netty.bootstrap.ConnectionlessBootstrap; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.SimpleChannelUpstreamHandler; +import org.jboss.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -60,7 +59,7 @@ public abstract class AbstractDatagramTest { public void testSimpleSend() throws Throwable { ConnectionlessBootstrap sb = new ConnectionlessBootstrap(newServerSocketChannelFactory(executor)); ConnectionlessBootstrap cb = new ConnectionlessBootstrap(newClientSocketChannelFactory(executor)); - + final CountDownLatch latch = new CountDownLatch(1); sb.getPipeline().addFirst("handler", new SimpleChannelUpstreamHandler() { @@ -71,7 +70,7 @@ public abstract class AbstractDatagramTest { latch.countDown(); } - + }); cb.getPipeline().addFirst("handler", new SimpleChannelUpstreamHandler()); @@ -85,6 +84,6 @@ public abstract class AbstractDatagramTest { assertTrue(latch.await(10, TimeUnit.SECONDS)); sc.close().awaitUninterruptibly(); cc.close().awaitUninterruptibly(); - + } } diff --git a/src/test/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfigTest.java b/src/test/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfigTest.java index 040cba1db1..225e8301e5 100644 --- a/src/test/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfigTest.java +++ b/src/test/java/org/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfigTest.java @@ -15,8 +15,6 @@ */ package org.jboss.netty.channel.socket.nio; -import org.jboss.netty.util.internal.DetectionUtil; - import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; @@ -27,6 +25,7 @@ import java.util.Enumeration; import junit.framework.Assert; +import org.jboss.netty.util.internal.DetectionUtil; import org.junit.Test; public class DefaultNioDatagramChannelConfigTest { @@ -37,7 +36,7 @@ public class DefaultNioDatagramChannelConfigTest { if (DetectionUtil.javaVersion() < 7) { return; } - + StandardProtocolFamily family = null; NetworkInterface inf = null; Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); @@ -58,19 +57,19 @@ public class DefaultNioDatagramChannelConfigTest { // No usable interface found so just skip the test return; } - + DefaultNioDatagramChannelConfig config = new DefaultNioDatagramChannelConfig(DatagramChannel.open(family)); config.setNetworkInterface(inf); Assert.assertEquals(inf, config.getNetworkInterface()); - + InetAddress localhost = inf.getInetAddresses().nextElement(); config.setInterface(localhost); Assert.assertEquals(localhost, config.getInterface()); - + config.setTimeToLive(100); Assert.assertEquals(100, config.getTimeToLive()); - + config.setLoopbackModeDisabled(false); Assert.assertEquals(false, config.isLoopbackModeDisabled()); } diff --git a/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java index 8e4944b23d..c04697d66a 100644 --- a/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java @@ -15,9 +15,7 @@ */ package org.jboss.netty.handler.codec.http; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.*; import java.text.DateFormat; import java.util.Date; @@ -126,7 +124,7 @@ public class CookieEncoderTest { String encodedCookie = encoder.encode(); assertEquals(c1 + c2 + c3, encodedCookie); } - + @Test public void testEncodingWithNoCookies() { CookieEncoder encoderForServer = new CookieEncoder(true); @@ -134,8 +132,8 @@ public class CookieEncoderTest { CookieEncoder encoderForClient = new CookieEncoder(false); String encodedCookie2 = encoderForClient.encode(); assertNotNull(encodedCookie1); - assertNotNull(encodedCookie2); - + assertNotNull(encodedCookie2); + } - + } diff --git a/src/test/java/org/jboss/netty/handler/codec/http/HttpClientCodecTest.java b/src/test/java/org/jboss/netty/handler/codec/http/HttpClientCodecTest.java index 4bda7566bb..38db977b7c 100644 --- a/src/test/java/org/jboss/netty/handler/codec/http/HttpClientCodecTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/http/HttpClientCodecTest.java @@ -15,8 +15,7 @@ */ package org.jboss.netty.handler.codec.http; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -31,7 +30,7 @@ public class HttpClientCodecTest { private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" + "Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n" + "\r\n"; - private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" +"5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n"; private static final String CHUNKED_RESPONSE = INCOMPLETE_CHUNKED_RESPONSE + "\r\n"; @@ -40,34 +39,34 @@ public class HttpClientCodecTest { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); DecoderEmbedder decoder = new DecoderEmbedder(codec); EncoderEmbedder encoder = new EncoderEmbedder(codec); - + encoder.offer(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); decoder.offer(ChannelBuffers.copiedBuffer(RESPONSE, CharsetUtil.ISO_8859_1)); encoder.finish(); decoder.finish(); - + } - + @Test public void testFailsNotOnRequestResponseChunked() { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); DecoderEmbedder decoder = new DecoderEmbedder(codec); EncoderEmbedder encoder = new EncoderEmbedder(codec); - + encoder.offer(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); decoder.offer(ChannelBuffers.copiedBuffer(CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1)); encoder.finish(); decoder.finish(); - + } - + @Test public void testFailsOnMissingResponse() { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); EncoderEmbedder encoder = new EncoderEmbedder(codec); - + encoder.offer(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); try { @@ -76,16 +75,16 @@ public class HttpClientCodecTest { } catch (CodecEmbedderException e) { assertTrue(e.getCause() instanceof PrematureChannelClosureException); } - + } - + @Test public void testFailsOnIncompleteChunkedResponse() { HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true); DecoderEmbedder decoder = new DecoderEmbedder(codec); EncoderEmbedder encoder = new EncoderEmbedder(codec); - + encoder.offer(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/")); decoder.offer(ChannelBuffers.copiedBuffer(INCOMPLETE_CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1)); @@ -96,6 +95,6 @@ public class HttpClientCodecTest { } catch (CodecEmbedderException e) { assertTrue(e.getCause() instanceof PrematureChannelClosureException); } - + } } diff --git a/src/test/java/org/jboss/netty/handler/codec/http/QueryStringDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/http/QueryStringDecoderTest.java index 6dc327d5c2..2c8e99ddf0 100644 --- a/src/test/java/org/jboss/netty/handler/codec/http/QueryStringDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/http/QueryStringDecoderTest.java @@ -110,7 +110,7 @@ public class QueryStringDecoderTest { } Assert.assertEquals(1024, new QueryStringDecoder(buf.toString()).getParameters().size()); } - + @Test public void testHasPath() throws Exception { QueryStringDecoder decoder = new QueryStringDecoder("1=2", false); @@ -167,7 +167,7 @@ public class QueryStringDecoderTest { Assert.assertEquals(ed.getPath(), ad.getPath()); Assert.assertEquals(ed.getParameters(), ad.getParameters()); } - + // See #189 @Test public void testURI() { @@ -177,26 +177,26 @@ public class QueryStringDecoderTest { Map> params = decoder.getParameters(); Assert.assertEquals(3, params.size()); Iterator>> entries = params.entrySet().iterator(); - + Entry> entry = entries.next(); Assert.assertEquals("param1", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value2", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param3", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value3", entry.getValue().get(0)); - + Assert.assertFalse(entries.hasNext()); } - + // See #189 @Test public void testURISlashPath() { @@ -206,26 +206,26 @@ public class QueryStringDecoderTest { Map> params = decoder.getParameters(); Assert.assertEquals(3, params.size()); Iterator>> entries = params.entrySet().iterator(); - + Entry> entry = entries.next(); Assert.assertEquals("param1", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value2", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param3", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value3", entry.getValue().get(0)); - + Assert.assertFalse(entries.hasNext()); } - + // See #189 @Test public void testURINoPath() { @@ -235,23 +235,23 @@ public class QueryStringDecoderTest { Map> params = decoder.getParameters(); Assert.assertEquals(3, params.size()); Iterator>> entries = params.entrySet().iterator(); - + Entry> entry = entries.next(); Assert.assertEquals("param1", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value1", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param2", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value2", entry.getValue().get(0)); - + entry = entries.next(); Assert.assertEquals("param3", entry.getKey()); Assert.assertEquals(1, entry.getValue().size()); Assert.assertEquals("value3", entry.getValue().get(0)); - + Assert.assertFalse(entries.hasNext()); } } diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java index 0f4d758315..5567c093c2 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java @@ -15,9 +15,7 @@ */ package org.jboss.netty.handler.codec.marshalling; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -43,68 +41,68 @@ public abstract class AbstractCompatibleMarshallingDecoderTest { public void testSimpleUnmarshalling() throws IOException { MarshallerFactory marshallerFactory = createMarshallerFactory(); MarshallingConfiguration configuration = createMarshallingConfig(); - + DecoderEmbedder decoder = new DecoderEmbedder(createDecoder(Integer.MAX_VALUE)); - + ByteArrayOutputStream bout = new ByteArrayOutputStream(); Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(Marshalling.createByteOutput(bout)); marshaller.writeObject(testObject); marshaller.finish(); marshaller.close(); - + byte[] testBytes = bout.toByteArray(); - + decoder.offer(input(testBytes)); assertTrue(decoder.finish()); - + String unmarshalled = (String) decoder.poll(); - + Assert.assertEquals(testObject, unmarshalled); - + Assert.assertNull(decoder.poll()); } - + protected ChannelBuffer input(byte[] input) { return ChannelBuffers.wrappedBuffer(input); } - + @Test public void testFragmentedUnmarshalling() throws IOException { MarshallerFactory marshallerFactory = createMarshallerFactory(); MarshallingConfiguration configuration = createMarshallingConfig(); - + DecoderEmbedder decoder = new DecoderEmbedder(createDecoder(Integer.MAX_VALUE)); - + ByteArrayOutputStream bout = new ByteArrayOutputStream(); Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(Marshalling.createByteOutput(bout)); marshaller.writeObject(testObject); marshaller.finish(); marshaller.close(); - + byte[] testBytes = bout.toByteArray(); - + ChannelBuffer buffer = input(testBytes); ChannelBuffer slice = buffer.readSlice(2); - + decoder.offer(slice); decoder.offer(buffer); assertTrue(decoder.finish()); - - + + String unmarshalled = (String) decoder.poll(); - + Assert.assertEquals(testObject, unmarshalled); - + Assert.assertNull(decoder.poll()); } - + @Test public void testTooBigObject() throws IOException { MarshallerFactory marshallerFactory = createMarshallerFactory(); MarshallingConfiguration configuration = createMarshallingConfig(); - + ChannelUpstreamHandler mDecoder = createDecoder(4); DecoderEmbedder decoder = new DecoderEmbedder(mDecoder); @@ -114,7 +112,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest { marshaller.writeObject(testObject); marshaller.finish(); marshaller.close(); - + byte[] testBytes = bout.toByteArray(); try { @@ -122,21 +120,21 @@ public abstract class AbstractCompatibleMarshallingDecoderTest { fail(); } catch (CodecEmbedderException e) { assertEquals(TooLongFrameException.class, e.getCause().getClass()); - - - } + + + } } - + protected ChannelUpstreamHandler createDecoder(int maxObjectSize) { return new CompatibleMarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); } - + protected UnmarshallerProvider createProvider(MarshallerFactory factory, MarshallingConfiguration config) { return new DefaultUnmarshallerProvider(factory, config); } - + protected abstract MarshallerFactory createMarshallerFactory(); protected abstract MarshallingConfiguration createMarshallingConfig(); diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java index 078531cc5b..e1fd8713b3 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java @@ -33,26 +33,26 @@ public abstract class AbstractCompatibleMarshallingEncoderTest { @Test public void testMarshalling() throws IOException, ClassNotFoundException { String testObject = new String("test"); - + final MarshallerFactory marshallerFactory = createMarshallerFactory(); final MarshallingConfiguration configuration = createMarshallingConfig(); - + EncoderEmbedder encoder = new EncoderEmbedder(createEncoder()); encoder.offer(testObject); Assert.assertTrue(encoder.finish()); - + ChannelBuffer buffer = encoder.poll(); - + Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration); unmarshaller.start(Marshalling.createByteInput(truncate(buffer).toByteBuffer())); String read = (String) unmarshaller.readObject(); Assert.assertEquals(testObject, read); - + Assert.assertEquals(-1, unmarshaller.read()); Assert.assertNull(encoder.poll()); - + unmarshaller.finish(); unmarshaller.close(); } @@ -67,9 +67,9 @@ public abstract class AbstractCompatibleMarshallingEncoderTest { protected MarshallerProvider createProvider() { return new DefaultMarshallerProvider(createMarshallerFactory(), createMarshallingConfig()); } - + protected abstract MarshallerFactory createMarshallerFactory(); protected abstract MarshallingConfiguration createMarshallingConfig(); - + } diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java index 14d95c264c..648c57bf3c 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverMarshallingDecoderTest.java @@ -27,11 +27,11 @@ public class RiverMarshallingDecoderTest extends RiverCompatibleMarshallingDecod length.writeInt(input.length); return ChannelBuffers.wrappedBuffer(length, ChannelBuffers.wrappedBuffer(input)); } - + @Override protected ChannelUpstreamHandler createDecoder(int maxObjectSize) { return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); } - + } diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingEncoderTest.java index 9c9746a5bf..b7500fb1b0 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalCompatibleMarshallingEncoderTest.java @@ -16,7 +16,7 @@ package org.jboss.netty.handler.codec.marshalling; public class RiverThreadLocalCompatibleMarshallingEncoderTest extends RiverCompatibleMarshallingEncoderTest { - + @Override protected MarshallerProvider createProvider() { return new ThreadLocalMarshallerProvider(createMarshallerFactory(), createMarshallingConfig()); diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalMarshallingEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalMarshallingEncoderTest.java index 629709aa73..9e7d6f93dc 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalMarshallingEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/RiverThreadLocalMarshallingEncoderTest.java @@ -16,7 +16,7 @@ package org.jboss.netty.handler.codec.marshalling; public class RiverThreadLocalMarshallingEncoderTest extends RiverMarshallingEncoderTest { - + @Override protected MarshallerProvider createProvider() { return new ThreadLocalMarshallerProvider(createMarshallerFactory(), createMarshallingConfig()); diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java index 23b490bc5d..74fbec2488 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialMarshallingDecoderTest.java @@ -20,17 +20,17 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.ChannelUpstreamHandler; public class SerialMarshallingDecoderTest extends SerialCompatibleMarshallingDecoderTest { - + @Override protected ChannelBuffer input(byte[] input) { ChannelBuffer length = ChannelBuffers.buffer(4); length.writeInt(input.length); return ChannelBuffers.wrappedBuffer(length, ChannelBuffers.wrappedBuffer(input)); } - + @Override protected ChannelUpstreamHandler createDecoder(int maxObjectSize) { return new MarshallingDecoder(createProvider(createMarshallerFactory(), createMarshallingConfig()), maxObjectSize); } - + } diff --git a/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialThreadLocalMarshallingEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialThreadLocalMarshallingEncoderTest.java index 1f06a8ee11..750344a641 100644 --- a/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialThreadLocalMarshallingEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/marshalling/SerialThreadLocalMarshallingEncoderTest.java @@ -16,7 +16,7 @@ package org.jboss.netty.handler.codec.marshalling; public class SerialThreadLocalMarshallingEncoderTest extends SerialMarshallingEncoderTest { - + @Override protected MarshallerProvider createProvider() { return new ThreadLocalMarshallerProvider(createMarshallerFactory(), createMarshallingConfig()); diff --git a/src/test/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderTest.java index d271e91543..2f6564a3ed 100644 --- a/src/test/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderTest.java @@ -72,14 +72,14 @@ public class ReplayingDecoderTest { fail.set(false); throw new Exception(); - + } - - + + buffer.readByte(); return new Object(); } - + }); try { e.offer(ChannelBuffers.copiedBuffer("TESTME!!!!", CharsetUtil.US_ASCII)); @@ -87,8 +87,8 @@ public class ReplayingDecoderTest { } catch (CodecEmbedderException ex) { // expected } - - // this will trigger an assert error when asserts are enabled via the -ea + + // this will trigger an assert error when asserts are enabled via the -ea // jvm switch. This is the default when run via the maven sunfire plugin e.offer(ChannelBuffers.copiedBuffer("TESTME!!!!", CharsetUtil.US_ASCII)); e.finish(); diff --git a/src/test/java/org/jboss/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java b/src/test/java/org/jboss/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java index 7ed75ee021..e210a49b07 100644 --- a/src/test/java/org/jboss/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/spdy/AbstractSocketSpdyEchoTest.java @@ -15,9 +15,8 @@ */ package org.jboss.netty.handler.codec.spdy; -import static org.junit.Assert.*; - import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*; +import static org.junit.Assert.*; import java.io.IOException; import java.net.InetSocketAddress; @@ -32,11 +31,11 @@ import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; @@ -54,7 +53,7 @@ public abstract class AbstractSocketSpdyEchoTest { private static ExecutorService executor; private static ChannelBuffer createFrames(int version) { - int length = (version < 3) ? 1176 : 1174; + int length = version < 3 ? 1176 : 1174; ChannelBuffer frames = ChannelBuffers.buffer(length); // SPDY UNKNOWN Frame diff --git a/src/test/java/org/jboss/netty/handler/ssl/SslCloseTest.java b/src/test/java/org/jboss/netty/handler/ssl/SslCloseTest.java index 54a48181bc..c1f41af7cb 100644 --- a/src/test/java/org/jboss/netty/handler/ssl/SslCloseTest.java +++ b/src/test/java/org/jboss/netty/handler/ssl/SslCloseTest.java @@ -56,16 +56,16 @@ public class SslCloseTest { System.out.println("Close channel"); ctx.getChannel().close(); } - + }); - + Channel serverChannel = sb.bind(new InetSocketAddress(0)); - + Channel cc = cb.connect(serverChannel.getLocalAddress()).awaitUninterruptibly().getChannel(); cc.write(ChannelBuffers.copiedBuffer("unencrypted", CharsetUtil.US_ASCII)).awaitUninterruptibly(); - + Assert.assertTrue(cc.getCloseFuture().awaitUninterruptibly(5000)); - + cb.releaseExternalResources(); sb.releaseExternalResources(); } diff --git a/src/test/java/org/jboss/netty/util/TestUtil.java b/src/test/java/org/jboss/netty/util/TestUtil.java index b74b7e9529..a6ea1a4e39 100644 --- a/src/test/java/org/jboss/netty/util/TestUtil.java +++ b/src/test/java/org/jboss/netty/util/TestUtil.java @@ -29,7 +29,7 @@ public final class TestUtil { private static final InetAddress LOCALHOST; private final static int START_PORT = 20000; private final static int END_PORT = 30000; - + static { InetAddress localhost = null; try { @@ -57,10 +57,10 @@ public final class TestUtil { return LOCALHOST; } - + /** * Return a free port which can be used to bind to - * + * * @return port */ public static int getFreePort() { @@ -71,9 +71,9 @@ public final class TestUtil { socket.close(); return start; } catch (IOException e) { - // ignore + // ignore } - + } throw new RuntimeException("Unable to find a free port...."); }