Code cleanup
This commit is contained in:
parent
6184456689
commit
fd0b0a4e2b
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-buffer</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-codec-http</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -22,6 +22,8 @@ package io.netty.handler.codec.spdy;
|
||||
*/
|
||||
public class SpdyProtocolException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -1097979786367505658L;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-codec</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-example</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -15,18 +15,19 @@
|
||||
*/
|
||||
package io.netty.example.objectecho;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPipelineFactory;
|
||||
import io.netty.channel.Channels;
|
||||
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import io.netty.example.echo.EchoClient;
|
||||
import io.netty.handler.codec.serialization.ClassResolvers;
|
||||
import io.netty.handler.codec.serialization.ObjectDecoder;
|
||||
import io.netty.handler.codec.serialization.ObjectEncoder;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Modification of {@link EchoClient} which utilizes Java object serialization.
|
||||
*/
|
||||
@ -50,10 +51,12 @@ public class ObjectEchoClient {
|
||||
|
||||
// Set up the pipeline factory.
|
||||
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() throws Exception {
|
||||
return Channels.pipeline(
|
||||
new ObjectEncoder(),
|
||||
new ObjectDecoder(),
|
||||
new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())),
|
||||
new ObjectEchoClientHandler(firstMessageSize));
|
||||
}
|
||||
});
|
||||
|
@ -15,18 +15,19 @@
|
||||
*/
|
||||
package io.netty.example.objectecho;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ChannelPipelineFactory;
|
||||
import io.netty.channel.Channels;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import io.netty.example.echo.EchoServer;
|
||||
import io.netty.handler.codec.serialization.ClassResolvers;
|
||||
import io.netty.handler.codec.serialization.ObjectDecoder;
|
||||
import io.netty.handler.codec.serialization.ObjectEncoder;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Modification of {@link EchoServer} which utilizes Java object serialization.
|
||||
*/
|
||||
@ -46,10 +47,12 @@ public class ObjectEchoServer {
|
||||
|
||||
// Set up the pipeline factory.
|
||||
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
|
||||
@Override
|
||||
public ChannelPipeline getPipeline() throws Exception {
|
||||
return Channels.pipeline(
|
||||
new ObjectEncoder(),
|
||||
new ObjectDecoder(),
|
||||
new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())),
|
||||
new ObjectEchoServerHandler());
|
||||
}
|
||||
});
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-handler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-testsuite</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -16,15 +16,6 @@
|
||||
package io.netty.testsuite.transport.socket;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
@ -35,10 +26,20 @@ import io.netty.channel.ChannelStateEvent;
|
||||
import io.netty.channel.ExceptionEvent;
|
||||
import io.netty.channel.MessageEvent;
|
||||
import io.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import io.netty.handler.codec.serialization.ClassResolvers;
|
||||
import io.netty.handler.codec.serialization.ObjectDecoder;
|
||||
import io.netty.handler.codec.serialization.ObjectEncoder;
|
||||
import io.netty.util.SocketAddresses;
|
||||
import io.netty.util.internal.ExecutorUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -83,11 +84,13 @@ public abstract class AbstractSocketObjectStreamEchoTest {
|
||||
EchoHandler sh = new EchoHandler();
|
||||
EchoHandler ch = new EchoHandler();
|
||||
|
||||
sb.getPipeline().addLast("decoder", new ObjectDecoder());
|
||||
sb.getPipeline().addLast("decoder", new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())));
|
||||
sb.getPipeline().addLast("encoder", new ObjectEncoder());
|
||||
sb.getPipeline().addLast("handler", sh);
|
||||
|
||||
cb.getPipeline().addLast("decoder", new ObjectDecoder());
|
||||
cb.getPipeline().addLast("decoder", new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())));
|
||||
cb.getPipeline().addLast("encoder", new ObjectEncoder());
|
||||
cb.getPipeline().addLast("handler", ch);
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-http</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-rxtx</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-sctp</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
package com.sun.nio.sctp;
|
||||
|
||||
public class UnsupportedOperatingSystemException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -221782446524784377L;
|
||||
|
||||
public static void raise() {
|
||||
throw new UnsupportedOperatingSystemException();
|
||||
}
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
package io.netty.channel.sctp;
|
||||
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.Channels;
|
||||
|
||||
import com.sun.nio.sctp.AbstractNotificationHandler;
|
||||
import com.sun.nio.sctp.AssociationChangeNotification;
|
||||
import com.sun.nio.sctp.HandlerResult;
|
||||
@ -23,20 +26,17 @@ import com.sun.nio.sctp.PeerAddressChangeNotification;
|
||||
import com.sun.nio.sctp.SendFailedNotification;
|
||||
import com.sun.nio.sctp.ShutdownNotification;
|
||||
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.Channels;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
class SctpNotificationHandler extends AbstractNotificationHandler {
|
||||
class SctpNotificationHandler extends AbstractNotificationHandler<Object> {
|
||||
|
||||
private final SctpChannelImpl sctpChannel;
|
||||
private final ChannelPipeline pipeline;
|
||||
|
||||
SctpNotificationHandler(SctpChannelImpl sctpChannel) {
|
||||
this.sctpChannel = sctpChannel;
|
||||
this.pipeline = sctpChannel.getPipeline();
|
||||
pipeline = sctpChannel.getPipeline();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,16 +15,7 @@
|
||||
*/
|
||||
package io.netty.channel.sctp;
|
||||
|
||||
import static io.netty.channel.Channels.fireChannelBound;
|
||||
import static io.netty.channel.Channels.fireChannelClosed;
|
||||
import static io.netty.channel.Channels.fireChannelConnected;
|
||||
import static io.netty.channel.Channels.fireChannelDisconnected;
|
||||
import static io.netty.channel.Channels.fireChannelInterestChanged;
|
||||
import static io.netty.channel.Channels.fireChannelUnbound;
|
||||
import static io.netty.channel.Channels.fireExceptionCaught;
|
||||
import static io.netty.channel.Channels.fireMessageReceived;
|
||||
import static io.netty.channel.Channels.fireWriteComplete;
|
||||
import static io.netty.channel.Channels.succeededFuture;
|
||||
import static io.netty.channel.Channels.*;
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBufferFactory;
|
||||
import io.netty.channel.Channel;
|
||||
@ -61,7 +52,6 @@ import com.sun.nio.sctp.MessageInfo;
|
||||
|
||||
/**
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
class SctpWorker implements Worker {
|
||||
|
||||
private static final InternalLogger logger =
|
||||
@ -249,7 +239,7 @@ class SctpWorker implements Worker {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void executeInIoThread(Runnable task) {
|
||||
if (Thread.currentThread() == thread) {
|
||||
@ -261,15 +251,15 @@ class SctpWorker implements Worker {
|
||||
// wake up the selector to speed things
|
||||
selector.wakeup();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static boolean isIoThread(SctpChannelImpl channel) {
|
||||
return Thread.currentThread() == channel.worker.thread;
|
||||
}
|
||||
|
||||
|
||||
private void processRegisterTaskQueue() throws IOException {
|
||||
for (; ;) {
|
||||
final Runnable task = registerTaskQueue.poll();
|
||||
@ -293,7 +283,7 @@ class SctpWorker implements Worker {
|
||||
cleanUpCancelledKeys();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processEventQueue() throws IOException {
|
||||
for (;;) {
|
||||
final Runnable task = eventQueue.poll();
|
||||
@ -304,7 +294,7 @@ class SctpWorker implements Worker {
|
||||
cleanUpCancelledKeys();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processSelectedKeys(final Set<SelectionKey> selectedKeys) throws IOException {
|
||||
for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
|
||||
SelectionKey k = i.next();
|
||||
|
@ -15,18 +15,24 @@
|
||||
*/
|
||||
package io.netty.testsuite.transport;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelStateEvent;
|
||||
import io.netty.channel.ExceptionEvent;
|
||||
import io.netty.channel.MessageEvent;
|
||||
import io.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import io.netty.channel.sctp.codec.SctpFrameDecoder;
|
||||
import io.netty.channel.sctp.codec.SctpFrameEncoder;
|
||||
import io.netty.handler.codec.serialization.ClassResolvers;
|
||||
import io.netty.handler.codec.serialization.ObjectDecoder;
|
||||
import io.netty.handler.codec.serialization.ObjectEncoder;
|
||||
import io.netty.testsuite.util.SctpSocketAddresses;
|
||||
import io.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -36,8 +42,9 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class AbstractSocketObjectStreamEchoTest {
|
||||
|
||||
@ -81,13 +88,15 @@ public abstract class AbstractSocketObjectStreamEchoTest {
|
||||
|
||||
sb.getPipeline().addLast("sctp-decoder", new SctpFrameDecoder());
|
||||
sb.getPipeline().addLast("sctp-encoder", new SctpFrameEncoder());
|
||||
sb.getPipeline().addLast("decoder", new ObjectDecoder());
|
||||
sb.getPipeline().addLast("decoder", new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())));
|
||||
sb.getPipeline().addLast("encoder", new ObjectEncoder());
|
||||
sb.getPipeline().addLast("handler", sh);
|
||||
|
||||
cb.getPipeline().addLast("sctp-decoder", new SctpFrameDecoder());
|
||||
cb.getPipeline().addLast("sctp-encoder", new SctpFrameEncoder());
|
||||
cb.getPipeline().addLast("decoder", new ObjectDecoder());
|
||||
cb.getPipeline().addLast("decoder", new ObjectDecoder(
|
||||
ClassResolvers.cacheDisabled(getClass().getClassLoader())));
|
||||
cb.getPipeline().addLast("encoder", new ObjectEncoder());
|
||||
cb.getPipeline().addLast("handler", ch);
|
||||
|
||||
|
@ -15,20 +15,28 @@
|
||||
*/
|
||||
package io.netty.testsuite.transport.sctp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.bootstrap.ClientBootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.sctp.*;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelStateEvent;
|
||||
import io.netty.channel.ExceptionEvent;
|
||||
import io.netty.channel.MessageEvent;
|
||||
import io.netty.channel.sctp.SctpChannel;
|
||||
import io.netty.channel.sctp.SctpClientSocketChannelFactory;
|
||||
import io.netty.channel.sctp.SctpNotificationEvent;
|
||||
import io.netty.channel.sctp.SctpServerChannel;
|
||||
import io.netty.channel.sctp.SctpServerSocketChannelFactory;
|
||||
import io.netty.channel.sctp.codec.SctpFrameDecoder;
|
||||
import io.netty.channel.sctp.codec.SctpFrameEncoder;
|
||||
import io.netty.channel.sctp.handler.SimpleSctpChannelHandler;
|
||||
import io.netty.testsuite.util.SctpSocketAddresses;
|
||||
import io.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@ -39,8 +47,9 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SctpMultiHomingEchoTest {
|
||||
private static final Random random = new Random();
|
||||
@ -152,7 +161,7 @@ public class SctpMultiHomingEchoTest {
|
||||
assertTrue(multiHomingUnbindFuture.awaitUninterruptibly().isSuccess());
|
||||
|
||||
ChannelFuture multiHomingServerUnbindFuture = serverChannel.unbindAddress(InetAddress.getByName(SctpSocketAddresses.LOOP_BACK2));
|
||||
assertTrue(multiHomingUnbindFuture.awaitUninterruptibly().isSuccess());
|
||||
assertTrue(multiHomingServerUnbindFuture.awaitUninterruptibly().isSuccess());
|
||||
|
||||
|
||||
sh.channel.close().awaitUninterruptibly();
|
||||
|
@ -23,7 +23,6 @@
|
||||
<version>4.0.0.Alpha1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user