Permalink
Browse files

Code cleanup

  • Loading branch information...
1 parent 6184456 commit fd0b0a4e2be5ccaeff5ea0a6c1c995c114f09a10 @trustin trustin committed Mar 30, 2012
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<packaging>jar</packaging>
View
@@ -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 @@
*/
public class SpdyProtocolException extends Exception {
+ private static final long serialVersionUID = -1097979786367505658L;
+
/**
* Creates a new instance.
*/
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<packaging>jar</packaging>
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<packaging>jar</packaging>
View
@@ -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 void run() {
// 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 void run() {
// 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());
}
});
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<packaging>jar</packaging>
View
@@ -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.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 void testObjectEcho() throws Throwable {
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);
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-transport-http</artifactId>
<packaging>jar</packaging>
View
@@ -23,7 +23,6 @@
<version>4.0.0.Alpha1-SNAPSHOT</version>
</parent>
- <groupId>io.netty</groupId>
<artifactId>netty-transport-rxtx</artifactId>
<packaging>jar</packaging>
View
@@ -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.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 @@
/**
*/
-@SuppressWarnings("unchecked")
class SctpWorker implements Worker {
private static final InternalLogger logger =
@@ -249,7 +239,7 @@ public void run() {
}
}
}
-
+
@Override
public void executeInIoThread(Runnable task) {
if (Thread.currentThread() == thread) {
@@ -261,15 +251,15 @@ public void executeInIoThread(Runnable task) {
// 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 @@ private void processWriteTaskQueue() throws IOException {
cleanUpCancelledKeys();
}
}
-
+
private void processEventQueue() throws IOException {
for (;;) {
final Runnable task = eventQueue.poll();
@@ -304,7 +294,7 @@ private void processEventQueue() throws IOException {
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.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 void testObjectEcho() throws Throwable {
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);
Oops, something went wrong.

0 comments on commit fd0b0a4

Please sign in to comment.