diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelAddress.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelAddress.java
index eff711cf8e..4212272d8f 100644
--- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelAddress.java
+++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelAddress.java
@@ -26,15 +26,40 @@ import java.net.URI;
/**
* @author Andy Taylor
+ * @author Trustin Lee (tlee@redhat.com)
*/
-public class HttpTunnelAddress extends SocketAddress {
+public class HttpTunnelAddress extends SocketAddress implements Comparable {
+
+ private static final long serialVersionUID = -7933609652910855887L;
+
private final URI uri;
public HttpTunnelAddress(URI uri) {
+ if (uri == null) {
+ throw new NullPointerException("uri");
+ }
this.uri = uri;
}
public URI getUri() {
return uri;
}
+
+ @Override
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof HttpTunnelAddress)) {
+ return false;
+ }
+
+ return getUri().equals(((HttpTunnelAddress) o).getUri());
+ }
+
+ public int compareTo(HttpTunnelAddress o) {
+ return getUri().toASCIIString().compareTo(o.getUri().toASCIIString());
+ }
}
diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannel.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannel.java
index 3330860256..efd3dbf85e 100644
--- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannel.java
+++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannel.java
@@ -163,7 +163,7 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
channel.write(ChannelBuffers.wrappedBuffer(msg.getBytes("ASCII7")));
}
- public void sendChunk(ChannelBuffer a) throws IOException {
+ public void sendChunk(ChannelBuffer a) {
int size = a.readableBytes();
String hex = Integer.toHexString(size) + HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR;
@@ -176,7 +176,7 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
}
}
- public byte[] receiveChunk() throws IOException {
+ public byte[] receiveChunk() {
byte[] buf = null;
try {
buf = messages.take();
@@ -187,7 +187,7 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
return buf;
}
- void reconnect() throws Exception{
+ void reconnect() throws Exception {
if (closed) {
throw new IllegalStateException("channel closed");
}
@@ -211,13 +211,13 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
}
}
- public void closeSocket() throws IOException {
+ public void closeSocket() {
setClosed();
closed = true;
channel.close();
}
- public void bindSocket(SocketAddress localAddress) throws IOException {
+ public void bindSocket(SocketAddress localAddress) {
channel.bind(localAddress);
}
diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannelFactory.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannelFactory.java
index 18c34fb186..671da19676 100644
--- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannelFactory.java
+++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelClientSocketChannelFactory.java
@@ -22,7 +22,6 @@
*/
package org.jboss.netty.channel.socket.http;
-import java.net.URL;
import java.util.concurrent.Executor;
import org.jboss.netty.channel.ChannelPipeline;
diff --git a/src/main/java/org/jboss/netty/example/http/HttpTunnelClientExample.java b/src/main/java/org/jboss/netty/example/http/HttpTunnelClientExample.java
index b715f0c35e..69fc8829ac 100644
--- a/src/main/java/org/jboss/netty/example/http/HttpTunnelClientExample.java
+++ b/src/main/java/org/jboss/netty/example/http/HttpTunnelClientExample.java
@@ -23,8 +23,6 @@ package org.jboss.netty.example.http;
import java.io.BufferedReader;
import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
-import java.net.URL;
import java.net.URI;
import java.util.concurrent.Executors;
@@ -33,8 +31,8 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
-import org.jboss.netty.channel.socket.http.HttpTunnelClientSocketChannelFactory;
import org.jboss.netty.channel.socket.http.HttpTunnelAddress;
+import org.jboss.netty.channel.socket.http.HttpTunnelClientSocketChannelFactory;
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import org.jboss.netty.handler.codec.string.StringDecoder;
@@ -97,8 +95,6 @@ public class HttpTunnelClientExample {
URI uri = new URI(args[0]);
String scheme = uri.getScheme() == null? "http" : uri.getScheme();
- String host = uri.getHost() == null? "localhost" : uri.getHost();
- int port = uri.getPort() == -1? 80 : uri.getPort();
if (!scheme.equals("http")) {
// We can actually support HTTPS fairly easily by inserting
diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpRequestEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpRequestEncoder.java
index c2d5111cf8..183ee8a7b9 100644
--- a/src/main/java/org/jboss/netty/handler/codec/http/HttpRequestEncoder.java
+++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpRequestEncoder.java
@@ -49,6 +49,7 @@ public class HttpRequestEncoder extends HttpMessageEncoder {
buf.writeBytes(CRLF);
}
+ @Override
public byte[] getCookieHeaderName() {
return COOKIE_HEADER;
}
diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseEncoder.java
index d453b11433..5bb388c0c2 100644
--- a/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseEncoder.java
+++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpResponseEncoder.java
@@ -47,7 +47,8 @@ public class HttpResponseEncoder extends HttpMessageEncoder {
buf.writeBytes(CRLF);
}
+ @Override
public byte[] getCookieHeaderName() {
- return COOKIE_HEADER;
- }
+ return COOKIE_HEADER;
+ }
}