Code clean up
This commit is contained in:
parent
b6aa509f32
commit
d24c48cbfb
@ -50,6 +50,14 @@ public abstract class AbstractChannelSink implements ChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if the specified {@code actualCause}, which was raised while
|
||||
* handling the specified {@code event}, must trigger an {@code exceptionCaught()} event in
|
||||
* an I/O thread.
|
||||
*
|
||||
* @param event the event which raised exception
|
||||
* @param actualCause the raised exception
|
||||
*/
|
||||
protected boolean isFireExceptionCaughtLater(ChannelEvent event, Throwable actualCause) {
|
||||
return false;
|
||||
}
|
||||
|
@ -65,6 +65,8 @@ public class ChannelLocal<T> implements Iterable<Entry<Channel, T>> {
|
||||
/**
|
||||
* Returns the initial value of the variable. By default, it returns
|
||||
* {@code null}. Override it to change the initial value.
|
||||
*
|
||||
* @param channel the channel where this local variable is accessed with
|
||||
*/
|
||||
protected T initialValue(Channel channel) {
|
||||
return null;
|
||||
|
@ -338,7 +338,7 @@ public class DefaultChannelFuture implements ChannelFuture {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDeadLock() {
|
||||
private static void checkDeadLock() {
|
||||
if (isUseDeadLockChecker() && DeadLockProofWorker.PARENT.get() != null) {
|
||||
throw new IllegalStateException(
|
||||
"await*() in I/O thread causes a dead lock or " +
|
||||
|
@ -316,7 +316,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return ctx.getHandler();
|
||||
}
|
||||
|
||||
private void callBeforeAdd(ChannelHandlerContext ctx) {
|
||||
private static void callBeforeAdd(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -366,7 +366,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callBeforeRemove(ChannelHandlerContext ctx) {
|
||||
private static void callBeforeRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -383,7 +383,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callAfterRemove(ChannelHandlerContext ctx) {
|
||||
private static void callAfterRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -425,7 +425,6 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized <T extends ChannelHandler> T get(Class<T> handlerType) {
|
||||
ChannelHandlerContext ctx = getContext(handlerType);
|
||||
if (ctx == null) {
|
||||
|
@ -179,7 +179,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private void callBeforeAdd(ChannelHandlerContext ctx) {
|
||||
private static void callBeforeAdd(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -196,7 +196,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callAfterAdd(ChannelHandlerContext ctx) {
|
||||
private static void callAfterAdd(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -228,7 +228,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callBeforeRemove(ChannelHandlerContext ctx) {
|
||||
private static void callBeforeRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -245,7 +245,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callAfterRemove(ChannelHandlerContext ctx) {
|
||||
private static void callAfterRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
@ -279,7 +279,6 @@ public class StaticChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends ChannelHandler> T get(Class<T> handlerType) {
|
||||
ChannelHandlerContext ctx = getContext(handlerType);
|
||||
if (ctx == null) {
|
||||
|
@ -315,7 +315,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDeadLock() {
|
||||
private static void checkDeadLock() {
|
||||
if (DeadLockProofWorker.PARENT.get() != null) {
|
||||
throw new IllegalStateException(
|
||||
"await*() in I/O thread causes a dead lock or " +
|
||||
|
@ -85,7 +85,7 @@ final class LocalClientChannelSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void bind(DefaultLocalChannel channel, ChannelFuture future, LocalAddress localAddress) {
|
||||
private static void bind(DefaultLocalChannel channel, ChannelFuture future, LocalAddress localAddress) {
|
||||
try {
|
||||
if (!LocalChannelRegistry.register(localAddress, channel)) {
|
||||
throw new ChannelException("address already in use: " + localAddress);
|
||||
|
@ -42,7 +42,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleServerChannel(ChannelEvent e) {
|
||||
private static void handleServerChannel(ChannelEvent e) {
|
||||
if (!(e instanceof ChannelStateEvent)) {
|
||||
return;
|
||||
}
|
||||
@ -69,7 +69,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAcceptedChannel(ChannelEvent e) {
|
||||
private static void handleAcceptedChannel(ChannelEvent e) {
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
ChannelStateEvent event = (ChannelStateEvent) e;
|
||||
DefaultLocalChannel channel = (DefaultLocalChannel) event.getChannel();
|
||||
@ -103,7 +103,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void bind(DefaultLocalServerChannel channel, ChannelFuture future, LocalAddress localAddress) {
|
||||
private static void bind(DefaultLocalServerChannel channel, ChannelFuture future, LocalAddress localAddress) {
|
||||
try {
|
||||
if (!LocalChannelRegistry.register(localAddress, channel)) {
|
||||
throw new ChannelException("address already in use: " + localAddress);
|
||||
@ -122,7 +122,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void close(DefaultLocalServerChannel channel, ChannelFuture future) {
|
||||
private static void close(DefaultLocalServerChannel channel, ChannelFuture future) {
|
||||
try {
|
||||
if (channel.setClosed()) {
|
||||
future.setSuccess();
|
||||
|
@ -15,17 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelInterestChanged;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.AbstractChannel;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer;
|
||||
import org.jboss.netty.util.internal.QueueFactory;
|
||||
import org.jboss.netty.util.internal.ThreadLocalBoolean;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
@ -38,6 +28,17 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.AbstractChannel;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer;
|
||||
import org.jboss.netty.util.internal.QueueFactory;
|
||||
import org.jboss.netty.util.internal.ThreadLocalBoolean;
|
||||
|
||||
abstract class AbstractNioChannel<C extends SelectableChannel & WritableByteChannel> extends AbstractChannel {
|
||||
|
||||
/**
|
||||
@ -127,8 +128,7 @@ abstract class AbstractNioChannel<C extends SelectableChannel & WritableByteChan
|
||||
InetSocketAddress localAddress = this.localAddress;
|
||||
if (localAddress == null) {
|
||||
try {
|
||||
this.localAddress = localAddress =
|
||||
(InetSocketAddress) getLocalSocketAddress();
|
||||
this.localAddress = localAddress = getLocalSocketAddress();
|
||||
} catch (Throwable t) {
|
||||
// Sometimes fails on a closed socket in Windows.
|
||||
return null;
|
||||
@ -142,7 +142,7 @@ abstract class AbstractNioChannel<C extends SelectableChannel & WritableByteChan
|
||||
if (remoteAddress == null) {
|
||||
try {
|
||||
this.remoteAddress = remoteAddress =
|
||||
(InetSocketAddress) getRemoteSocketAddress();
|
||||
getRemoteSocketAddress();
|
||||
} catch (Throwable t) {
|
||||
// Sometimes fails on a closed socket in Windows.
|
||||
return null;
|
||||
|
@ -162,7 +162,7 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
try {
|
||||
return (NetworkInterface) channel.getOption(StandardSocketOptions.IP_MULTICAST_IF);
|
||||
return channel.getOption(StandardSocketOptions.IP_MULTICAST_IF);
|
||||
} catch (IOException e) {
|
||||
throw new ChannelException(e);
|
||||
}
|
||||
@ -175,7 +175,7 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
try {
|
||||
return (int) channel.getOption(StandardSocketOptions.IP_MULTICAST_TTL);
|
||||
return channel.getOption(StandardSocketOptions.IP_MULTICAST_TTL);
|
||||
} catch (IOException e) {
|
||||
throw new ChannelException(e);
|
||||
}
|
||||
@ -225,7 +225,7 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
try {
|
||||
return (Boolean) channel.getOption(StandardSocketOptions.IP_MULTICAST_LOOP);
|
||||
return channel.getOption(StandardSocketOptions.IP_MULTICAST_LOOP);
|
||||
} catch (IOException e) {
|
||||
throw new ChannelException(e);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void bind(
|
||||
private static void bind(
|
||||
NioClientSocketChannel channel, ChannelFuture future,
|
||||
SocketAddress localAddress) {
|
||||
try {
|
||||
@ -175,7 +175,7 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
||||
private final AtomicBoolean wakenUp = new AtomicBoolean();
|
||||
private final Object startStopLock = new Object();
|
||||
private final Queue<Runnable> registerTaskQueue = QueueFactory.createQueue(Runnable.class);
|
||||
private final int subId;;
|
||||
private final int subId;
|
||||
|
||||
Boss(int subId) {
|
||||
this.subId = subId;
|
||||
|
@ -15,15 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelOpen;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
import org.jboss.netty.util.internal.DetectionUtil;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@ -39,6 +31,15 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
import org.jboss.netty.util.internal.DetectionUtil;
|
||||
|
||||
/**
|
||||
* Provides an NIO based {@link org.jboss.netty.channel.socket.DatagramChannel}.
|
||||
*/
|
||||
@ -130,6 +131,7 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
|
||||
return super.setClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NioDatagramChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
@ -234,7 +236,7 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
|
||||
while (keyIt.hasNext()) {
|
||||
MembershipKey key = keyIt.next();
|
||||
if (networkInterface.equals(key.networkInterface())) {
|
||||
if (source == null && key.sourceAddress() == null || (source != null && source.equals(key.sourceAddress()))) {
|
||||
if (source == null && key.sourceAddress() == null || source != null && source.equals(key.sourceAddress())) {
|
||||
key.drop();
|
||||
keyIt.remove();
|
||||
}
|
||||
|
@ -41,6 +41,5 @@ import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
* </table>
|
||||
*/
|
||||
public interface NioDatagramChannelConfig extends DatagramChannelConfig, NioChannelConfig {
|
||||
|
||||
|
||||
// Tag interface
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.group.ChannelGroup;
|
||||
import org.jboss.netty.channel.socket.DatagramChannel;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelFactory;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.channel.socket.nio.NioDatagramChannel.ProtocolFamily;
|
||||
import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory;
|
||||
import org.jboss.netty.util.ExternalResourceReleasable;
|
||||
|
@ -98,7 +98,7 @@ class NioDatagramPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void close(NioDatagramChannel channel, ChannelFuture future) {
|
||||
private static void close(NioDatagramChannel channel, ChannelFuture future) {
|
||||
try {
|
||||
channel.getDatagramChannel().socket().close();
|
||||
if (channel.setClosed()) {
|
||||
@ -120,7 +120,7 @@ class NioDatagramPipelineSink extends AbstractNioChannelSink {
|
||||
* Will bind the DatagramSocket to the passed-in address.
|
||||
* Every call bind will spawn a new thread using the that basically in turn
|
||||
*/
|
||||
private void bind(final NioDatagramChannel channel,
|
||||
private static void bind(final NioDatagramChannel channel,
|
||||
final ChannelFuture future, final InetSocketAddress address) {
|
||||
boolean bound = false;
|
||||
boolean started = false;
|
||||
@ -144,7 +144,7 @@ class NioDatagramPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void connect(
|
||||
private static void connect(
|
||||
NioDatagramChannel channel, ChannelFuture future,
|
||||
SocketAddress remoteAddress) {
|
||||
|
||||
|
@ -21,8 +21,8 @@ import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -231,13 +231,7 @@ final class NioProviderMetadata {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static final class ConstraintLevelAutodetector {
|
||||
|
||||
ConstraintLevelAutodetector() {
|
||||
super();
|
||||
}
|
||||
|
||||
int autodetect() {
|
||||
private static int autodetect() {
|
||||
final int constraintLevel;
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
boolean success;
|
||||
@ -405,7 +399,6 @@ final class NioProviderMetadata {
|
||||
|
||||
return constraintLevel;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SelectorLoop implements Runnable {
|
||||
final Selector selector;
|
||||
@ -449,9 +442,7 @@ final class NioProviderMetadata {
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("Hard-coded Constraint Level: " + CONSTRAINT_LEVEL);
|
||||
System.out.println(
|
||||
"Auto-detected Constraint Level: " +
|
||||
new ConstraintLevelAutodetector().autodetect());
|
||||
System.out.println("Auto-detected Constraint Level: " + autodetect());
|
||||
}
|
||||
|
||||
private NioProviderMetadata() {
|
||||
|
@ -95,7 +95,7 @@ class NioServerSocketPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAcceptedSocket(ChannelEvent e) {
|
||||
private static void handleAcceptedSocket(ChannelEvent e) {
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
ChannelStateEvent event = (ChannelStateEvent) e;
|
||||
NioSocketChannel channel = (NioSocketChannel) event.getChannel();
|
||||
@ -157,7 +157,7 @@ class NioServerSocketPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void close(NioServerSocketChannel channel, ChannelFuture future) {
|
||||
private static void close(NioServerSocketChannel channel, ChannelFuture future) {
|
||||
boolean bound = channel.isBound();
|
||||
try {
|
||||
if (channel.socket.isOpen()) {
|
||||
|
@ -50,6 +50,7 @@ public class NioSocketChannel extends AbstractNioChannel<SocketChannel>
|
||||
return (NioWorker) super.getWorker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NioSocketChannelConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
@ -78,6 +79,7 @@ public class NioSocketChannel extends AbstractNioChannel<SocketChannel>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setClosed() {
|
||||
state = ST_CLOSED;
|
||||
return super.setClosed();
|
||||
|
@ -78,8 +78,7 @@ abstract class AbstractOioChannel extends AbstractChannel {
|
||||
InetSocketAddress localAddress = this.localAddress;
|
||||
if (localAddress == null) {
|
||||
try {
|
||||
this.localAddress = localAddress =
|
||||
(InetSocketAddress) getLocalSocketAddress();
|
||||
this.localAddress = localAddress = getLocalSocketAddress();
|
||||
} catch (Throwable t) {
|
||||
// Sometimes fails on a closed socket in Windows.
|
||||
return null;
|
||||
@ -94,7 +93,7 @@ abstract class AbstractOioChannel extends AbstractChannel {
|
||||
if (remoteAddress == null) {
|
||||
try {
|
||||
this.remoteAddress = remoteAddress =
|
||||
(InetSocketAddress) getRemoteSocketAddress();
|
||||
getRemoteSocketAddress();
|
||||
} catch (Throwable t) {
|
||||
// Sometimes fails on a closed socket in Windows.
|
||||
return null;
|
||||
|
@ -50,25 +50,25 @@ class OioClientSocketPipelineSink extends AbstractOioChannelSink {
|
||||
switch (state) {
|
||||
case OPEN:
|
||||
if (Boolean.FALSE.equals(value)) {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case BOUND:
|
||||
if (value != null) {
|
||||
bind(channel, future, (SocketAddress) value);
|
||||
} else {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
if (value != null) {
|
||||
connect(channel, future, (SocketAddress) value);
|
||||
} else {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case INTEREST_OPS:
|
||||
OioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
AbstractOioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
break;
|
||||
}
|
||||
} else if (e instanceof MessageEvent) {
|
||||
@ -78,7 +78,7 @@ class OioClientSocketPipelineSink extends AbstractOioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void bind(
|
||||
private static void bind(
|
||||
OioClientSocketChannel channel, ChannelFuture future,
|
||||
SocketAddress localAddress) {
|
||||
try {
|
||||
@ -129,7 +129,7 @@ class OioClientSocketPipelineSink extends AbstractOioChannelSink {
|
||||
fireExceptionCaught(channel, t);
|
||||
} finally {
|
||||
if (connected && !workerStarted) {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ class OioDatagramPipelineSink extends AbstractOioChannelSink {
|
||||
switch (state) {
|
||||
case OPEN:
|
||||
if (Boolean.FALSE.equals(value)) {
|
||||
OioDatagramWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case BOUND:
|
||||
if (value != null) {
|
||||
bind(channel, future, (SocketAddress) value);
|
||||
} else {
|
||||
OioDatagramWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
@ -67,7 +67,7 @@ class OioDatagramPipelineSink extends AbstractOioChannelSink {
|
||||
}
|
||||
break;
|
||||
case INTEREST_OPS:
|
||||
OioDatagramWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
AbstractOioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
break;
|
||||
}
|
||||
} else if (e instanceof MessageEvent) {
|
||||
@ -102,7 +102,7 @@ class OioDatagramPipelineSink extends AbstractOioChannelSink {
|
||||
fireExceptionCaught(channel, t);
|
||||
} finally {
|
||||
if (bound && !workerStarted) {
|
||||
OioDatagramWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ class OioDatagramPipelineSink extends AbstractOioChannelSink {
|
||||
fireExceptionCaught(channel, t);
|
||||
} finally {
|
||||
if (connected && !workerStarted) {
|
||||
OioDatagramWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class OioServerSocketPipelineSink extends AbstractOioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAcceptedSocket(ChannelEvent e) {
|
||||
private static void handleAcceptedSocket(ChannelEvent e) {
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
ChannelStateEvent event = (ChannelStateEvent) e;
|
||||
OioAcceptedSocketChannel channel =
|
||||
@ -96,17 +96,17 @@ class OioServerSocketPipelineSink extends AbstractOioChannelSink {
|
||||
switch (state) {
|
||||
case OPEN:
|
||||
if (Boolean.FALSE.equals(value)) {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case BOUND:
|
||||
case CONNECTED:
|
||||
if (value == null) {
|
||||
OioWorker.close(channel, future);
|
||||
AbstractOioWorker.close(channel, future);
|
||||
}
|
||||
break;
|
||||
case INTEREST_OPS:
|
||||
OioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
AbstractOioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
|
||||
break;
|
||||
}
|
||||
} else if (e instanceof MessageEvent) {
|
||||
@ -150,7 +150,7 @@ class OioServerSocketPipelineSink extends AbstractOioChannelSink {
|
||||
}
|
||||
}
|
||||
|
||||
private void close(OioServerSocketChannel channel, ChannelFuture future) {
|
||||
private static void close(OioServerSocketChannel channel, ChannelFuture future) {
|
||||
boolean bound = channel.isBound();
|
||||
try {
|
||||
channel.socket.close();
|
||||
|
@ -211,7 +211,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private String sanitizeUri(String uri) {
|
||||
private static String sanitizeUri(String uri) {
|
||||
// Decode the path.
|
||||
try {
|
||||
uri = URLDecoder.decode(uri, "UTF-8");
|
||||
@ -238,7 +238,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
return System.getProperty("user.dir") + File.separator + uri;
|
||||
}
|
||||
|
||||
private void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
|
||||
private static void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
|
||||
response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
|
||||
response.setContent(ChannelBuffers.copiedBuffer(
|
||||
@ -255,7 +255,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* @param ctx
|
||||
* Context
|
||||
*/
|
||||
private void sendNotModified(ChannelHandlerContext ctx) {
|
||||
private static void sendNotModified(ChannelHandlerContext ctx) {
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.NOT_MODIFIED);
|
||||
setDateHeader(response);
|
||||
|
||||
@ -269,7 +269,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* @param response
|
||||
* HTTP response
|
||||
*/
|
||||
private void setDateHeader(HttpResponse response) {
|
||||
private static void setDateHeader(HttpResponse response) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
|
||||
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
|
||||
|
||||
@ -285,7 +285,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* @param fileToCache
|
||||
* file to extract content type
|
||||
*/
|
||||
private void setDateAndCacheHeaders(HttpResponse response, File fileToCache) {
|
||||
private static void setDateAndCacheHeaders(HttpResponse response, File fileToCache) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
|
||||
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
|
||||
|
||||
@ -308,7 +308,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* @param file
|
||||
* file to extract content type
|
||||
*/
|
||||
private void setContentTypeHeader(HttpResponse response, File file) {
|
||||
private static void setContentTypeHeader(HttpResponse response, File file) {
|
||||
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class HttpSnoopServerHandler extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void send100Continue(MessageEvent e) {
|
||||
private static void send100Continue(MessageEvent e) {
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, CONTINUE);
|
||||
e.getChannel().write(response);
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
DiskAttribute.baseDirectory = null; // system temp directory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
|
||||
throws Exception {
|
||||
if (decoder != null) {
|
||||
@ -94,6 +95,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||
if (!readingChunks) {
|
||||
// clean previous FileUpload if Any
|
||||
@ -480,6 +482,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
e.getChannel().write(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
||||
throws Exception {
|
||||
logger.error(responseContent.toString(), e.getCause());
|
||||
|
@ -71,12 +71,12 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Handshake
|
||||
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
|
||||
this.getWebSocketLocation(req), null, false);
|
||||
this.handshaker = wsFactory.newHandshaker(req);
|
||||
if (this.handshaker == null) {
|
||||
getWebSocketLocation(req), null, false);
|
||||
handshaker = wsFactory.newHandshaker(req);
|
||||
if (handshaker == null) {
|
||||
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
|
||||
} else {
|
||||
this.handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
|
||||
if (frame instanceof CloseWebSocketFrame) {
|
||||
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
ctx.getChannel().write(
|
||||
new PongWebSocketFrame(frame.isFinalFragment(), frame.getRsv(), frame.getBinaryData()));
|
||||
@ -110,7 +110,7 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
// Generate an error page if response status code is not OK (200).
|
||||
if (res.getStatus().getCode() != 200) {
|
||||
res.setContent(ChannelBuffers.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
|
||||
@ -130,7 +130,7 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
|
||||
e.getChannel().close();
|
||||
}
|
||||
|
||||
private String getWebSocketLocation(HttpRequest req) {
|
||||
private static String getWebSocketLocation(HttpRequest req) {
|
||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST);
|
||||
}
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ public class WebSocketClient {
|
||||
ChannelFuture future =
|
||||
bootstrap.connect(
|
||||
new InetSocketAddress(uri.getHost(), uri.getPort()));
|
||||
future.awaitUninterruptibly().rethrowIfFailed();
|
||||
future.syncUninterruptibly();
|
||||
|
||||
ch = future.getChannel();
|
||||
handshaker.handshake(ch).awaitUninterruptibly().rethrowIfFailed();
|
||||
handshaker.handshake(ch).syncUninterruptibly();
|
||||
|
||||
// Send 10 messages and wait for responses
|
||||
System.out.println("WebSocket Client sending message");
|
||||
|
@ -16,8 +16,9 @@
|
||||
|
||||
/**
|
||||
* <p>This is an example web service client.
|
||||
* <p>To run this example, you must first start {@link WebSocketServer} and
|
||||
* then {@link WebSocketClient}.
|
||||
* <p>To run this example, you must first start
|
||||
* {@link org.jboss.netty.example.http.websocketx.server.WebSocketServer} and then
|
||||
* {@link org.jboss.netty.example.http.websocketx.client.WebSocketClient}.
|
||||
*/
|
||||
package org.jboss.netty.example.http.websocketx.client;
|
||||
|
||||
|
@ -91,12 +91,12 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Handshake
|
||||
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
|
||||
this.getWebSocketLocation(req), null, false);
|
||||
this.handshaker = wsFactory.newHandshaker(req);
|
||||
if (this.handshaker == null) {
|
||||
getWebSocketLocation(req), null, false);
|
||||
handshaker = wsFactory.newHandshaker(req);
|
||||
if (handshaker == null) {
|
||||
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
|
||||
} else {
|
||||
this.handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Check for closing frame
|
||||
if (frame instanceof CloseWebSocketFrame) {
|
||||
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
return;
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
|
||||
@ -122,7 +122,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
||||
}
|
||||
|
||||
private void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
// Generate an error page if response status code is not OK (200).
|
||||
if (res.getStatus().getCode() != 200) {
|
||||
res.setContent(ChannelBuffers.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
|
||||
@ -142,7 +142,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||
e.getChannel().close();
|
||||
}
|
||||
|
||||
private String getWebSocketLocation(HttpRequest req) {
|
||||
private static String getWebSocketLocation(HttpRequest req) {
|
||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||
}
|
||||
}
|
||||
|
@ -91,12 +91,12 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Handshake
|
||||
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
|
||||
this.getWebSocketLocation(req), null, false);
|
||||
this.handshaker = wsFactory.newHandshaker(req);
|
||||
if (this.handshaker == null) {
|
||||
getWebSocketLocation(req), null, false);
|
||||
handshaker = wsFactory.newHandshaker(req);
|
||||
if (handshaker == null) {
|
||||
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
|
||||
} else {
|
||||
this.handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
handshaker.handshake(ctx.getChannel(), req).addListener(WebSocketServerHandshaker.HANDSHAKE_LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
||||
|
||||
// Check for closing frame
|
||||
if (frame instanceof CloseWebSocketFrame) {
|
||||
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||
return;
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
|
||||
@ -122,7 +122,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
||||
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
||||
}
|
||||
|
||||
private void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
|
||||
// Generate an error page if response status code is not OK (200).
|
||||
if (res.getStatus().getCode() != 200) {
|
||||
res.setContent(ChannelBuffers.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
|
||||
@ -142,7 +142,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
||||
e.getChannel().close();
|
||||
}
|
||||
|
||||
private String getWebSocketLocation(HttpRequest req) {
|
||||
private static String getWebSocketLocation(HttpRequest req) {
|
||||
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class PortUnificationServerHandler extends FrameDecoder {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isHttp(int magic1, int magic2) {
|
||||
private static boolean isHttp(int magic1, int magic2) {
|
||||
return
|
||||
magic1 == 'G' && magic2 == 'E' || // GET
|
||||
magic1 == 'P' && magic2 == 'O' || // POST
|
||||
@ -115,7 +115,7 @@ public class PortUnificationServerHandler extends FrameDecoder {
|
||||
magic1 == 'C' && magic2 == 'O'; // CONNECT
|
||||
}
|
||||
|
||||
private boolean isFactorial(int magic1) {
|
||||
private static boolean isFactorial(int magic1) {
|
||||
return magic1 == 'F';
|
||||
}
|
||||
|
||||
|
@ -123,12 +123,10 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
|
||||
return productQueue.isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final E poll() {
|
||||
return (E) productQueue.poll();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final E peek() {
|
||||
return (E) productQueue.peek();
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
|
||||
/**
|
||||
* Decodes the received {@link ChannelBuffer}s into a meaningful frame object.
|
||||
@ -207,7 +208,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
|
||||
callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
|
||||
if (input.readable()) {
|
||||
// seems like there is something readable left in the input buffer. So create the cumulation buffer and copy the input into it
|
||||
(this.cumulation = newCumulationBuffer(ctx, input.readableBytes())).writeBytes(input);
|
||||
(cumulation = newCumulationBuffer(ctx, input.readableBytes())).writeBytes(input);
|
||||
}
|
||||
} else {
|
||||
assert cumulation.readable();
|
||||
@ -233,23 +234,23 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
|
||||
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
|
||||
buf = ChannelBuffers.wrappedBuffer(cumulation, input);
|
||||
this.cumulation = buf;
|
||||
cumulation = buf;
|
||||
}
|
||||
|
||||
|
||||
callDecode(ctx, e.getChannel(), buf, e.getRemoteAddress());
|
||||
if (!buf.readable()) {
|
||||
// nothing readable left so reset the state
|
||||
this.cumulation = null;
|
||||
cumulation = null;
|
||||
} else {
|
||||
// create a new buffer and copy the readable buffer into it
|
||||
this.cumulation = newCumulationBuffer(ctx, buf.readableBytes());
|
||||
this.cumulation.writeBytes(buf);
|
||||
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
|
||||
cumulation.writeBytes(buf);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
* @return the array of bytes
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] readFrom(File src) throws IOException {
|
||||
private static byte[] readFrom(File src) throws IOException {
|
||||
long srcsize = src.length();
|
||||
if (srcsize > Integer.MAX_VALUE) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -32,6 +32,7 @@ final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
return o1.compareToIgnoreCase(o2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
private Object readResolve() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class CookieDecoder {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
private void extractKeyValuePairs(
|
||||
private static void extractKeyValuePairs(
|
||||
String header, List<String> names, List<String> values) {
|
||||
Matcher m = PATTERN.matcher(header);
|
||||
int pos = 0;
|
||||
@ -243,7 +243,7 @@ public class CookieDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
private String decodeValue(String value) {
|
||||
private static String decodeValue(String value) {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class HttpContentCompressor extends HttpContentEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
private ZlibWrapper determineWrapper(String acceptEncoding) {
|
||||
private static ZlibWrapper determineWrapper(String acceptEncoding) {
|
||||
float starQ = -1.0f;
|
||||
float gzipQ = -1.0f;
|
||||
float deflateQ = -1.0f;
|
||||
|
@ -405,7 +405,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
return message;
|
||||
}
|
||||
|
||||
private void skipControlCharacters(ChannelBuffer buffer) {
|
||||
private static void skipControlCharacters(ChannelBuffer buffer) {
|
||||
for (;;) {
|
||||
char c = (char) buffer.readUnsignedByte();
|
||||
if (!Character.isISOControl(c) &&
|
||||
@ -557,7 +557,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
protected abstract boolean isDecodingRequest();
|
||||
protected abstract HttpMessage createMessage(String[] initialLine) throws Exception;
|
||||
|
||||
private int getChunkSize(String hex) {
|
||||
private static int getChunkSize(String hex) {
|
||||
hex = hex.trim();
|
||||
for (int i = 0; i < hex.length(); i ++) {
|
||||
char c = hex.charAt(i);
|
||||
@ -570,7 +570,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
return Integer.parseInt(hex, 16);
|
||||
}
|
||||
|
||||
private String readLine(ChannelBuffer buffer, int maxLineLength) throws TooLongFrameException {
|
||||
private static String readLine(ChannelBuffer buffer, int maxLineLength) throws TooLongFrameException {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
int lineLength = 0;
|
||||
while (true) {
|
||||
@ -598,7 +598,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
}
|
||||
}
|
||||
|
||||
private String[] splitInitialLine(String sb) {
|
||||
private static String[] splitInitialLine(String sb) {
|
||||
int aStart;
|
||||
int aEnd;
|
||||
int bStart;
|
||||
@ -621,7 +621,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
cStart < cEnd? sb.substring(cStart, cEnd) : "" };
|
||||
}
|
||||
|
||||
private String[] splitHeader(String sb) {
|
||||
private static String[] splitHeader(String sb) {
|
||||
final int length = sb.length();
|
||||
int nameStart;
|
||||
int nameEnd;
|
||||
@ -659,7 +659,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
};
|
||||
}
|
||||
|
||||
private int findNonWhitespace(String sb, int offset) {
|
||||
private static int findNonWhitespace(String sb, int offset) {
|
||||
int result;
|
||||
for (result = offset; result < sb.length(); result ++) {
|
||||
if (!Character.isWhitespace(sb.charAt(result))) {
|
||||
@ -669,7 +669,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
return result;
|
||||
}
|
||||
|
||||
private int findWhitespace(String sb, int offset) {
|
||||
private static int findWhitespace(String sb, int offset) {
|
||||
int result;
|
||||
for (result = offset; result < sb.length(); result ++) {
|
||||
if (Character.isWhitespace(sb.charAt(result))) {
|
||||
@ -679,7 +679,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
return result;
|
||||
}
|
||||
|
||||
private int findEndOfString(String sb) {
|
||||
private static int findEndOfString(String sb) {
|
||||
int result;
|
||||
for (result = sb.length(); result > 0; result --) {
|
||||
if (!Character.isWhitespace(sb.charAt(result - 1))) {
|
||||
|
@ -136,7 +136,7 @@ public abstract class HttpMessageEncoder extends OneToOneEncoder {
|
||||
return msg;
|
||||
}
|
||||
|
||||
private void encodeHeaders(ChannelBuffer buf, HttpMessage message) {
|
||||
private static void encodeHeaders(ChannelBuffer buf, HttpMessage message) {
|
||||
try {
|
||||
for (Map.Entry<String, String> h: message.getHeaders()) {
|
||||
encodeHeader(buf, h.getKey(), h.getValue());
|
||||
@ -146,7 +146,7 @@ public abstract class HttpMessageEncoder extends OneToOneEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
private void encodeTrailingHeaders(ChannelBuffer buf, HttpChunkTrailer trailer) {
|
||||
private static void encodeTrailingHeaders(ChannelBuffer buf, HttpChunkTrailer trailer) {
|
||||
try {
|
||||
for (Map.Entry<String, String> h: trailer.getHeaders()) {
|
||||
encodeHeader(buf, h.getKey(), h.getValue());
|
||||
@ -156,7 +156,7 @@ public abstract class HttpMessageEncoder extends OneToOneEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
private void encodeHeader(ChannelBuffer buf, String header, String value)
|
||||
private static void encodeHeader(ChannelBuffer buf, String header, String value)
|
||||
throws UnsupportedEncodingException {
|
||||
buf.writeBytes(header.getBytes("ASCII"));
|
||||
buf.writeByte(COLON);
|
||||
|
@ -1696,7 +1696,7 @@ public class HttpPostRequestDecoder {
|
||||
* Clean the String from any unallowed character
|
||||
* @return the cleaned String
|
||||
*/
|
||||
private String cleanString(String field) {
|
||||
private static String cleanString(String field) {
|
||||
StringBuilder sb = new StringBuilder(field.length());
|
||||
int i = 0;
|
||||
for (i = 0; i < field.length(); i ++) {
|
||||
@ -1752,7 +1752,7 @@ public class HttpPostRequestDecoder {
|
||||
* @param sb
|
||||
* @return the array of 2 Strings
|
||||
*/
|
||||
private String[] splitHeaderContentType(String sb) {
|
||||
private static String[] splitHeaderContentType(String sb) {
|
||||
int size = sb.length();
|
||||
int aStart;
|
||||
int aEnd;
|
||||
@ -1778,7 +1778,7 @@ public class HttpPostRequestDecoder {
|
||||
* @return an array of String where rank 0 is the name of the header, follows by several
|
||||
* values that were separated by ';' or ','
|
||||
*/
|
||||
private String[] splitMultipartHeader(String sb) {
|
||||
private static String[] splitMultipartHeader(String sb) {
|
||||
ArrayList<String> headers = new ArrayList<String>(1);
|
||||
int nameStart;
|
||||
int nameEnd;
|
||||
|
@ -56,11 +56,11 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
/**
|
||||
* InterfaceHttpData for Body (without encoding)
|
||||
*/
|
||||
private List<InterfaceHttpData> bodyListDatas;
|
||||
private final List<InterfaceHttpData> bodyListDatas;
|
||||
/**
|
||||
* The final Multipart List of InterfaceHttpData including encoding
|
||||
*/
|
||||
private List<InterfaceHttpData> multipartHttpDatas;
|
||||
private final List<InterfaceHttpData> multipartHttpDatas;
|
||||
|
||||
/**
|
||||
* Does this request is a Multipart request
|
||||
@ -201,7 +201,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
*
|
||||
* @return a newly generated Delimiter (either for DATA or MIXED)
|
||||
*/
|
||||
private String getNewMultipartDelimiter() {
|
||||
private static String getNewMultipartDelimiter() {
|
||||
// construct a generated delimiter
|
||||
Random random = new Random();
|
||||
return Long.toHexString(random.nextLong()).toLowerCase();
|
||||
|
@ -24,6 +24,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
*
|
||||
* The default {@link WebSocketFrame} implementation.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultWebSocketFrame implements WebSocketFrame {
|
||||
|
||||
private int type;
|
||||
|
@ -23,6 +23,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
||||
*
|
||||
* A Web Socket frame that represents either text or binary data.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface WebSocketFrame {
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ import org.jboss.netty.handler.codec.replay.VoidEnum;
|
||||
* @apiviz.landmark
|
||||
* @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame
|
||||
*/
|
||||
@Deprecated
|
||||
public class WebSocketFrameDecoder extends ReplayingDecoder<VoidEnum> {
|
||||
|
||||
public static final int DEFAULT_MAX_FRAME_SIZE = 16384;
|
||||
|
@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.http.websocket;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -32,6 +32,7 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
* @apiviz.landmark
|
||||
* @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame
|
||||
*/
|
||||
@Deprecated
|
||||
@Sharable
|
||||
public class WebSocketFrameEncoder extends OneToOneEncoder {
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
private UTF8Output fragmentedFramesText;
|
||||
private int fragmentedFramesCount;
|
||||
|
||||
private long maxFramePayloadLength;
|
||||
private final long maxFramePayloadLength;
|
||||
private boolean frameFinalFlag;
|
||||
private int frameRsv;
|
||||
private int frameOpcode;
|
||||
@ -238,8 +238,8 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
framePayloadLength = framePayloadLen1;
|
||||
}
|
||||
|
||||
if (framePayloadLength > this.maxFramePayloadLength) {
|
||||
protocolViolation(channel, "Max frame length of " + this.maxFramePayloadLength + " has been exceeded.");
|
||||
if (framePayloadLength > maxFramePayloadLength) {
|
||||
protocolViolation(channel, "Max frame length of " + maxFramePayloadLength + " has been exceeded.");
|
||||
return null;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
@ -388,7 +388,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
throw new CorruptedFrameException(reason);
|
||||
}
|
||||
|
||||
private int toFrameLength(long l) throws TooLongFrameException {
|
||||
private static int toFrameLength(long l) throws TooLongFrameException {
|
||||
if (l > Integer.MAX_VALUE) {
|
||||
throw new TooLongFrameException("Length:" + l);
|
||||
} else {
|
||||
@ -429,8 +429,8 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
|
||||
// Must have 2 byte integer within the valid range
|
||||
int statusCode = buffer.readShort();
|
||||
if ((statusCode >= 0 && statusCode <= 999) || (statusCode >= 1004 && statusCode <= 1006)
|
||||
|| (statusCode >= 1012 && statusCode <= 2999)) {
|
||||
if (statusCode >= 0 && statusCode <= 999 || statusCode >= 1004 && statusCode <= 1006
|
||||
|| statusCode >= 1012 && statusCode <= 2999) {
|
||||
protocolViolation(channel, "Invalid close frame status code: " + statusCode);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1);
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2);
|
||||
String expectedSubprotocol = this.getExpectedSubprotocol();
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
|
||||
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -241,12 +241,12 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
setActualSubprotocol(subprotocol);
|
||||
|
||||
channel.getPipeline().replace(HttpResponseDecoder.class, "ws-decoder",
|
||||
new WebSocket00FrameDecoder(this.getMaxFramePayloadLength()));
|
||||
new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
|
||||
|
||||
setHandshakeComplete();
|
||||
}
|
||||
|
||||
private String insertRandomCharacters(String key) {
|
||||
private static String insertRandomCharacters(String key) {
|
||||
int count = WebSocketUtil.randomNumber(1, 12);
|
||||
|
||||
char[] randomChars = new char[count];
|
||||
@ -269,7 +269,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
return key;
|
||||
}
|
||||
|
||||
private String insertSpaces(String key, int spaces) {
|
||||
private static String insertSpaces(String key, int spaces) {
|
||||
for (int i = 0; i < spaces; i++) {
|
||||
int split = WebSocketUtil.randomNumber(1, key.length() - 1);
|
||||
String part1 = key.substring(0, split);
|
||||
|
@ -90,37 +90,37 @@ final class SpdyCodecUtil {
|
||||
* Reads a big-endian unsigned short integer from the buffer.
|
||||
*/
|
||||
static int getUnsignedShort(ChannelBuffer buf, int offset) {
|
||||
return (int) ((buf.getByte(offset) & 0xFF) << 8 |
|
||||
(buf.getByte(offset + 1) & 0xFF));
|
||||
return (buf.getByte(offset) & 0xFF) << 8 |
|
||||
buf.getByte(offset + 1) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a big-endian unsigned medium integer from the buffer.
|
||||
*/
|
||||
static int getUnsignedMedium(ChannelBuffer buf, int offset) {
|
||||
return (int) ((buf.getByte(offset) & 0xFF) << 16 |
|
||||
return (buf.getByte(offset) & 0xFF) << 16 |
|
||||
(buf.getByte(offset + 1) & 0xFF) << 8 |
|
||||
(buf.getByte(offset + 2) & 0xFF));
|
||||
buf.getByte(offset + 2) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a big-endian (31-bit) integer from the buffer.
|
||||
*/
|
||||
static int getUnsignedInt(ChannelBuffer buf, int offset) {
|
||||
return (int) ((buf.getByte(offset) & 0x7F) << 24 |
|
||||
return (buf.getByte(offset) & 0x7F) << 24 |
|
||||
(buf.getByte(offset + 1) & 0xFF) << 16 |
|
||||
(buf.getByte(offset + 2) & 0xFF) << 8 |
|
||||
(buf.getByte(offset + 3) & 0xFF));
|
||||
buf.getByte(offset + 3) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a big-endian signed integer from the buffer.
|
||||
*/
|
||||
static int getSignedInt(ChannelBuffer buf, int offset) {
|
||||
return (int) ((buf.getByte(offset) & 0xFF) << 24 |
|
||||
return (buf.getByte(offset) & 0xFF) << 24 |
|
||||
(buf.getByte(offset + 1) & 0xFF) << 16 |
|
||||
(buf.getByte(offset + 2) & 0xFF) << 8 |
|
||||
(buf.getByte(offset + 3) & 0xFF));
|
||||
buf.getByte(offset + 3) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,9 +45,20 @@ public class SpdyFrameCodec implements ChannelUpstreamHandler,
|
||||
* Creates a new instance with the specified decoder and encoder options.
|
||||
*/
|
||||
public SpdyFrameCodec(
|
||||
int maxChunkSize, int maxFrameSize, int maxHeaderSize,
|
||||
int maxChunkSize, int maxHeaderSize,
|
||||
int compressionLevel, int windowBits, int memLevel) {
|
||||
decoder = new SpdyFrameDecoder(maxChunkSize, maxFrameSize, maxHeaderSize);
|
||||
decoder = new SpdyFrameDecoder(maxChunkSize, maxHeaderSize);
|
||||
encoder = new SpdyFrameEncoder(compressionLevel, windowBits, memLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified decoder and encoder options.
|
||||
*/
|
||||
@Deprecated
|
||||
public SpdyFrameCodec(
|
||||
int maxChunkSize, @SuppressWarnings("unused") int maxFrameSize, int maxHeaderSize,
|
||||
int compressionLevel, int windowBits, int memLevel) {
|
||||
decoder = new SpdyFrameDecoder(maxChunkSize, maxHeaderSize);
|
||||
encoder = new SpdyFrameEncoder(compressionLevel, windowBits, memLevel);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
@ -23,8 +25,6 @@ import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
/**
|
||||
* Decodes {@link ChannelBuffer}s into SPDY Data and Control Frames.
|
||||
*/
|
||||
@ -76,7 +76,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
*/
|
||||
@Deprecated
|
||||
public SpdyFrameDecoder(
|
||||
int maxChunkSize, int maxFrameSize, int maxHeaderSize) {
|
||||
int maxChunkSize, @SuppressWarnings("unused") int maxFrameSize, int maxHeaderSize) {
|
||||
this(maxChunkSize, maxHeaderSize);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
}
|
||||
this.maxChunkSize = maxChunkSize;
|
||||
this.maxHeaderSize = maxHeaderSize;
|
||||
this.state = State.READ_COMMON_HEADER;
|
||||
state = State.READ_COMMON_HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,7 +166,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
// Chromium Issue 79156
|
||||
// SPDY setting ids are not written in network byte order
|
||||
// Read id assuming the architecture is little endian
|
||||
int ID = (buffer.readByte() & 0xFF) |
|
||||
int ID = buffer.readByte() & 0xFF |
|
||||
(buffer.readByte() & 0xFF) << 8 |
|
||||
(buffer.readByte() & 0xFF) << 16;
|
||||
byte ID_flags = buffer.readByte();
|
||||
@ -181,7 +181,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(spdySettingsFrame.isSet(ID))) {
|
||||
if (!spdySettingsFrame.isSet(ID)) {
|
||||
boolean persistVal = (ID_flags & SPDY_SETTINGS_PERSIST_VALUE) != 0;
|
||||
boolean persisted = (ID_flags & SPDY_SETTINGS_PERSISTED) != 0;
|
||||
spdySettingsFrame.setValue(ID, value, persistVal, persisted);
|
||||
@ -438,7 +438,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
|
||||
case SPDY_HEADERS_FRAME:
|
||||
// Protocol allows length 4 frame when there are no name/value pairs
|
||||
int minLength = (length == 4) ? 4 : 8;
|
||||
int minLength = length == 4 ? 4 : 8;
|
||||
if (buffer.readableBytes() < minLength) {
|
||||
return null;
|
||||
}
|
||||
@ -695,7 +695,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
fireProtocolException(ctx, message);
|
||||
}
|
||||
|
||||
private void fireProtocolException(ChannelHandlerContext ctx, String message) {
|
||||
private static void fireProtocolException(ChannelHandlerContext ctx, String message) {
|
||||
Channels.fireExceptionCaught(ctx, new SpdyProtocolException(message));
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Set;
|
||||
|
||||
@ -26,8 +28,6 @@ import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
/**
|
||||
* Encodes a SPDY Data or Control Frame into a {@link ChannelBuffer}.
|
||||
*/
|
||||
@ -99,7 +99,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
flags |= SPDY_FLAG_UNIDIRECTIONAL;
|
||||
}
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length = (headerBlockLength == 0) ? 12 : 10 + headerBlockLength;
|
||||
int length = headerBlockLength == 0 ? 12 : 10 + headerBlockLength;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length);
|
||||
frame.writeShort(SPDY_VERSION | 0x8000);
|
||||
@ -108,7 +108,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
frame.writeMedium(length);
|
||||
frame.writeInt(spdySynStreamFrame.getStreamID());
|
||||
frame.writeInt(spdySynStreamFrame.getAssociatedToStreamID());
|
||||
frame.writeShort(((short) spdySynStreamFrame.getPriority()) << 14);
|
||||
frame.writeShort((spdySynStreamFrame.getPriority() & 0xFF) << 14);
|
||||
if (data.readableBytes() == 0) {
|
||||
frame.writeShort(0);
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
encodeHeaderBlock(spdySynReplyFrame));
|
||||
byte flags = spdySynReplyFrame.isLast() ? SPDY_FLAG_FIN : 0;
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length = (headerBlockLength == 0) ? 8 : 6 + headerBlockLength;
|
||||
int length = headerBlockLength == 0 ? 8 : 6 + headerBlockLength;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length);
|
||||
frame.writeShort(SPDY_VERSION | 0x8000);
|
||||
@ -175,9 +175,9 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
// Chromium Issue 79156
|
||||
// SPDY setting ids are not written in network byte order
|
||||
// Write id assuming the architecture is little endian
|
||||
frame.writeByte((id >> 0) & 0xFF);
|
||||
frame.writeByte((id >> 8) & 0xFF);
|
||||
frame.writeByte((id >> 16) & 0xFF);
|
||||
frame.writeByte(id >> 0 & 0xFF);
|
||||
frame.writeByte(id >> 8 & 0xFF);
|
||||
frame.writeByte(id >> 16 & 0xFF);
|
||||
frame.writeByte(ID_flags);
|
||||
frame.writeInt(spdySettingsFrame.getValue(id));
|
||||
}
|
||||
@ -220,7 +220,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
ChannelBuffer data = compressHeaderBlock(
|
||||
encodeHeaderBlock(spdyHeadersFrame));
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length = (headerBlockLength == 0) ? 4 : 6 + headerBlockLength;
|
||||
int length = headerBlockLength == 0 ? 4 : 6 + headerBlockLength;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length);
|
||||
frame.writeShort(SPDY_VERSION | 0x8000);
|
||||
@ -237,7 +237,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
return msg;
|
||||
}
|
||||
|
||||
private ChannelBuffer encodeHeaderBlock(SpdyHeaderBlock headerFrame)
|
||||
private static ChannelBuffer encodeHeaderBlock(SpdyHeaderBlock headerFrame)
|
||||
throws Exception {
|
||||
Set<String> names = headerFrame.getHeaderNames();
|
||||
int numHeaders = names.size();
|
||||
|
@ -220,7 +220,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
||||
return null;
|
||||
}
|
||||
|
||||
private HttpRequest createHttpRequest(SpdyHeaderBlock requestFrame)
|
||||
private static HttpRequest createHttpRequest(SpdyHeaderBlock requestFrame)
|
||||
throws Exception {
|
||||
// Create the first line of the request from the name/value pairs
|
||||
HttpMethod method = SpdyHeaders.getMethod(requestFrame);
|
||||
@ -250,7 +250,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
private HttpResponse createHttpResponse(SpdyHeaderBlock responseFrame)
|
||||
private static HttpResponse createHttpResponse(SpdyHeaderBlock responseFrame)
|
||||
throws Exception {
|
||||
// Create the first line of the response from the name/value pairs
|
||||
HttpResponseStatus status = SpdyHeaders.getStatus(responseFrame);
|
||||
|
@ -19,4 +19,5 @@ package org.jboss.netty.handler.codec.spdy;
|
||||
* A SPDY Protocol NOOP Control Frame
|
||||
*/
|
||||
public interface SpdyNoOpFrame {
|
||||
// Tag interface
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
|
||||
private boolean isRemoteInitiatedID(int ID) {
|
||||
boolean serverID = SpdyCodecUtil.isServerID(ID);
|
||||
return (server && !serverID) || (!server && serverID);
|
||||
return server && !serverID || !server && serverID;
|
||||
}
|
||||
|
||||
private synchronized void updateConcurrentStreams(SpdySettingsFrame settings, boolean remote) {
|
||||
@ -429,8 +429,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
if (receivedGoAwayFrame || sentGoAwayFrame) {
|
||||
return false;
|
||||
}
|
||||
if ((maxConcurrentStreams != 0) &&
|
||||
(spdySession.numActiveStreams() >= maxConcurrentStreams)) {
|
||||
if (maxConcurrentStreams != 0 &&
|
||||
spdySession.numActiveStreams() >= maxConcurrentStreams) {
|
||||
return false;
|
||||
}
|
||||
spdySession.acceptStream(streamID, remoteSideClosed, localSideClosed);
|
||||
@ -446,14 +446,14 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
} else {
|
||||
spdySession.closeLocalSide(streamID);
|
||||
}
|
||||
if ((closeSessionFuture != null) && spdySession.noActiveStreams()) {
|
||||
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
||||
closeSessionFuture.setSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeStream(int streamID) {
|
||||
spdySession.removeStream(streamID);
|
||||
if ((closeSessionFuture != null) && spdySession.noActiveStreams()) {
|
||||
if (closeSessionFuture != null && spdySession.noActiveStreams()) {
|
||||
closeSessionFuture.setSuccess();
|
||||
}
|
||||
}
|
||||
@ -479,7 +479,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
if (!sentGoAwayFrame) {
|
||||
sentGoAwayFrame = true;
|
||||
ChannelFuture future = Channels.future(channel);
|
||||
Channels.write(ctx, future, new DefaultSpdyGoAwayFrame(lastGoodStreamID));
|
||||
Channels.write(ctx, future, new DefaultSpdyGoAwayFrame(lastGoodStreamID), remoteAddress);
|
||||
return future;
|
||||
}
|
||||
return Channels.succeededFuture(channel);
|
||||
|
@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelState;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
|
@ -239,7 +239,7 @@ public class BlockingReadHandler<E> extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void detectDeadLock() {
|
||||
private static void detectDeadLock() {
|
||||
if (DeadLockProofWorker.PARENT.get() != null) {
|
||||
throw new IllegalStateException(
|
||||
"read*(...) in I/O thread causes a dead lock or " +
|
||||
@ -267,7 +267,6 @@ public class BlockingReadHandler<E> extends SimpleChannelUpstreamHandler {
|
||||
getQueue().put(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private E getMessage(MessageEvent e) {
|
||||
return (E) e.getMessage();
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ public class SslHandler extends FrameDecoder
|
||||
* @deprecated Use {@link #handshake()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ChannelFuture handshake(Channel channel) {
|
||||
public ChannelFuture handshake(@SuppressWarnings("unused") Channel channel) {
|
||||
return handshake();
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ public class SslHandler extends FrameDecoder
|
||||
* @deprecated Use {@link #close()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ChannelFuture close(Channel channel) {
|
||||
public ChannelFuture close(@SuppressWarnings("unused") Channel channel) {
|
||||
return close();
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void destroy(ChannelHandlerContext ctx) {
|
||||
private static void destroy(ChannelHandlerContext ctx) {
|
||||
State state;
|
||||
|
||||
synchronized (ctx) {
|
||||
@ -329,7 +329,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private State state(ChannelHandlerContext ctx) {
|
||||
private static State state(ChannelHandlerContext ctx) {
|
||||
State state;
|
||||
synchronized (ctx) {
|
||||
// FIXME: It could have been better if there is setAttachmentIfAbsent().
|
||||
|
@ -198,7 +198,7 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void destroy(ChannelHandlerContext ctx) {
|
||||
private static void destroy(ChannelHandlerContext ctx) {
|
||||
State state;
|
||||
synchronized (ctx) {
|
||||
state = state(ctx);
|
||||
@ -211,7 +211,7 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
}
|
||||
|
||||
private State state(ChannelHandlerContext ctx) {
|
||||
private static State state(ChannelHandlerContext ctx) {
|
||||
State state;
|
||||
synchronized (ctx) {
|
||||
// FIXME: It could have been better if there is setAttachmentIfAbsent().
|
||||
|
@ -22,13 +22,13 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
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.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelDownstreamHandler;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.util.ExternalResourceReleasable;
|
||||
import org.jboss.netty.util.HashedWheelTimer;
|
||||
import org.jboss.netty.util.Timeout;
|
||||
@ -130,6 +130,13 @@ public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the write timeout of the specified event. By default, this method returns the
|
||||
* timeout value you specified in the constructor. Override this method to determine the
|
||||
* timeout value depending on the message being written.
|
||||
*
|
||||
* @param e the message being written
|
||||
*/
|
||||
protected long getTimeoutMillis(MessageEvent e) {
|
||||
return timeoutMillis;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
private int hashOf(Object key) {
|
||||
private static int hashOf(Object key) {
|
||||
return hash(key.hashCode());
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
private boolean keyEq(Object src, Object dest) {
|
||||
private static boolean keyEq(Object src, Object dest) {
|
||||
return src.equals(dest);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
private int hashOf(Object key) {
|
||||
private static int hashOf(Object key) {
|
||||
return hash(System.identityHashCode(key));
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
private boolean keyEq(Object src, Object dest) {
|
||||
private static boolean keyEq(Object src, Object dest) {
|
||||
return src == dest;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
private int hashOf(Object key) {
|
||||
private static int hashOf(Object key) {
|
||||
return hash(System.identityHashCode(key));
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
private boolean keyEq(Object src, Object dest) {
|
||||
private static boolean keyEq(Object src, Object dest) {
|
||||
return src == dest;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
return segments[hash >>> segmentShift & segmentMask];
|
||||
}
|
||||
|
||||
private int hashOf(Object key) {
|
||||
private static int hashOf(Object key) {
|
||||
return hash(key.hashCode());
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
||||
return new Segment[i];
|
||||
}
|
||||
|
||||
private boolean keyEq(Object src, Object dest) {
|
||||
private static boolean keyEq(Object src, Object dest) {
|
||||
return src.equals(dest);
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ public class LegacyLinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
throws java.io.IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
for (;;) {
|
||||
@SuppressWarnings("unchecked") E item = (E) s.readObject();
|
||||
E item = (E) s.readObject();
|
||||
if (item == null) {
|
||||
break;
|
||||
} else {
|
||||
|
@ -680,7 +680,7 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
(t = tail) != null &&
|
||||
(s = t.next) != null && // advance and retry
|
||||
(s = s.next) != null && s != t) {
|
||||
;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
@ -1383,7 +1383,6 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
throws java.io.IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
for (;;) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E item = (E) s.readObject();
|
||||
if (item == null) {
|
||||
break;
|
||||
|
@ -460,7 +460,7 @@ final class InfCodes {
|
||||
// at least ten. The ten bytes are six bytes for the longest length/
|
||||
// distance pair plus four bytes for overloading the bit buffer.
|
||||
|
||||
int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td,
|
||||
static int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td,
|
||||
int td_index, InfBlocks s, ZStream z) {
|
||||
int t; // temporary pointer
|
||||
int[] tp; // temporary pointer
|
||||
|
@ -562,7 +562,7 @@ final class Inflate {
|
||||
}
|
||||
}
|
||||
|
||||
int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) {
|
||||
static int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) {
|
||||
int index = 0;
|
||||
int length = dictLength;
|
||||
if (z == null || z.istate == null || z.istate.mode != DICT0) {
|
||||
|
@ -109,7 +109,7 @@ public final class ZStream {
|
||||
if (istate == null) {
|
||||
return JZlib.Z_STREAM_ERROR;
|
||||
}
|
||||
return istate.inflateSetDictionary(this, dictionary, dictLength);
|
||||
return Inflate.inflateSetDictionary(this, dictionary, dictLength);
|
||||
}
|
||||
|
||||
public int deflateInit(int level) {
|
||||
|
@ -93,7 +93,7 @@ public class ChunkedWriteHandlerTest {
|
||||
check(new ChunkedNioFile(TMP), new ChunkedNioFile(TMP), new ChunkedNioFile(TMP));
|
||||
}
|
||||
|
||||
private void check(ChunkedInput... inputs) {
|
||||
private static void check(ChunkedInput... inputs) {
|
||||
EncoderEmbedder<ChannelBuffer> embedder = new EncoderEmbedder<ChannelBuffer>(new ChunkedWriteHandler());
|
||||
for (ChunkedInput input: inputs) {
|
||||
embedder.offer(input);
|
||||
|
@ -15,18 +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.DatagramChannel;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelFactory;
|
||||
import org.jboss.netty.util.TestUtil;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -37,6 +26,15 @@ 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.TestUtil;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
@ -118,7 +116,7 @@ public abstract class AbstractDatagramMulticastTest {
|
||||
|
||||
}
|
||||
|
||||
private ChannelBuffer wrapInt(int value) {
|
||||
private static ChannelBuffer wrapInt(int value) {
|
||||
ChannelBuffer buf = ChannelBuffers.buffer(4);
|
||||
buf.writeInt(value);
|
||||
return buf;
|
||||
|
@ -18,9 +18,9 @@ package org.jboss.netty.handler.codec.spdy;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
|
||||
@ -36,7 +36,7 @@ public class SpdySessionHandlerTest {
|
||||
closeMessage.setValue(closeSignal, 0);
|
||||
}
|
||||
|
||||
private void assertHeaderBlock(SpdyHeaderBlock received, SpdyHeaderBlock expected) {
|
||||
private static void assertHeaderBlock(SpdyHeaderBlock received, SpdyHeaderBlock expected) {
|
||||
for (String name: expected.getHeaderNames()) {
|
||||
List<String> expectedValues = expected.getHeaders(name);
|
||||
List<String> receivedValues = received.getHeaders(name);
|
||||
@ -48,7 +48,7 @@ public class SpdySessionHandlerTest {
|
||||
Assert.assertTrue(received.getHeaders().isEmpty());
|
||||
}
|
||||
|
||||
private void assertDataFrame(Object msg, int streamID, boolean last) {
|
||||
private static void assertDataFrame(Object msg, int streamID, boolean last) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyDataFrame);
|
||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||
@ -56,7 +56,7 @@ public class SpdySessionHandlerTest {
|
||||
Assert.assertTrue(spdyDataFrame.isLast() == last);
|
||||
}
|
||||
|
||||
private void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
||||
private static void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdySynReplyFrame);
|
||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||
@ -65,7 +65,7 @@ public class SpdySessionHandlerTest {
|
||||
assertHeaderBlock(spdySynReplyFrame, headers);
|
||||
}
|
||||
|
||||
private void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
||||
private static void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyRstStreamFrame);
|
||||
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
||||
@ -73,21 +73,21 @@ public class SpdySessionHandlerTest {
|
||||
Assert.assertTrue(spdyRstStreamFrame.getStatus().equals(status));
|
||||
}
|
||||
|
||||
private void assertPing(Object msg, int ID) {
|
||||
private static void assertPing(Object msg, int ID) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyPingFrame);
|
||||
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
||||
Assert.assertTrue(spdyPingFrame.getID() == ID);
|
||||
}
|
||||
|
||||
private void assertGoAway(Object msg, int lastGoodStreamID) {
|
||||
private static void assertGoAway(Object msg, int lastGoodStreamID) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyGoAwayFrame);
|
||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||
Assert.assertTrue(spdyGoAwayFrame.getLastGoodStreamID() == lastGoodStreamID);
|
||||
}
|
||||
|
||||
private void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
||||
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyHeadersFrame);
|
||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||
@ -263,8 +263,8 @@ public class SpdySessionHandlerTest {
|
||||
// Echo Handler opens 4 half-closed streams on session connection
|
||||
// and then sets the number of concurrent streams to 3
|
||||
private class EchoHandler extends SimpleChannelUpstreamHandler {
|
||||
private int closeSignal;
|
||||
private boolean server;
|
||||
private final int closeSignal;
|
||||
private final boolean server;
|
||||
|
||||
EchoHandler(int closeSignal, boolean server) {
|
||||
super();
|
||||
@ -299,9 +299,9 @@ public class SpdySessionHandlerTest {
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
|
||||
throws Exception {
|
||||
Object msg = e.getMessage();
|
||||
if ((msg instanceof SpdyDataFrame) ||
|
||||
(msg instanceof SpdyPingFrame) ||
|
||||
(msg instanceof SpdyHeadersFrame)) {
|
||||
if (msg instanceof SpdyDataFrame ||
|
||||
msg instanceof SpdyPingFrame ||
|
||||
msg instanceof SpdyHeadersFrame) {
|
||||
|
||||
Channels.write(e.getChannel(), msg, e.getRemoteAddress());
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ public class StringUtilTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void assertStripped(final char controlCode) {
|
||||
private static void assertStripped(final char controlCode) {
|
||||
final Object object = "aaa" + controlCode + "bbb";
|
||||
final String stripped = StringUtil.stripControlCharacters(object);
|
||||
assertEquals("aaa bbb", stripped);
|
||||
|
Loading…
x
Reference in New Issue
Block a user