* Fixed compiler warnings
* HttpTunnelAddress should have proper hashCode, equals, and compareTo
This commit is contained in:
parent
5eb3a748c2
commit
a77664bf8f
@ -26,15 +26,40 @@ import java.net.URI;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
|
||||
* @author Trustin Lee (tlee@redhat.com)
|
||||
*/
|
||||
public class HttpTunnelAddress extends SocketAddress {
|
||||
public class HttpTunnelAddress extends SocketAddress implements Comparable<HttpTunnelAddress> {
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -49,6 +49,7 @@ public class HttpRequestEncoder extends HttpMessageEncoder {
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getCookieHeaderName() {
|
||||
return COOKIE_HEADER;
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ public class HttpResponseEncoder extends HttpMessageEncoder {
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getCookieHeaderName() {
|
||||
return COOKIE_HEADER;
|
||||
}
|
||||
return COOKIE_HEADER;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user