Fixed all compiler warnings

This commit is contained in:
Trustin Lee 2012-05-31 02:18:48 -07:00
parent def46a641e
commit 7fc2d40a24
13 changed files with 62 additions and 57 deletions

View File

@ -46,7 +46,7 @@ public class QuoteOfTheMomentClient {
public void run() { public void run() {
DatagramChannelFactory f = DatagramChannelFactory f =
new NioDatagramChannelFactory(Executors.newCachedThreadPool()); new NioDatagramChannelFactory(Executors.newCachedThreadPool(), null);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f); ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);

View File

@ -16,7 +16,6 @@
package org.jboss.netty.example.qotm; package org.jboss.netty.example.qotm;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipeline;
@ -24,6 +23,7 @@ import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory; import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
import org.jboss.netty.channel.socket.DatagramChannelFactory; import org.jboss.netty.channel.socket.DatagramChannelFactory;
import org.jboss.netty.channel.socket.nio.NioDatagramChannel.ProtocolFamily;
import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory; import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
import org.jboss.netty.handler.codec.string.StringDecoder; import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder; import org.jboss.netty.handler.codec.string.StringEncoder;
@ -45,7 +45,7 @@ public class QuoteOfTheMomentServer {
public void run() { public void run() {
DatagramChannelFactory f = DatagramChannelFactory f =
new NioDatagramChannelFactory(Executors.newCachedThreadPool()); new NioDatagramChannelFactory((ProtocolFamily) null);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f); ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);

View File

@ -31,6 +31,7 @@ import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler; import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler; 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. * Decodes the received {@link ChannelBuffer}s into a meaningful frame object.
@ -452,7 +453,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
* Use it only when you must use it at your own risk. * Use it only when you must use it at your own risk.
*/ */
protected ChannelBuffer internalBuffer() { protected ChannelBuffer internalBuffer() {
ChannelBuffer buf = this.cumulation; ChannelBuffer buf = cumulation;
if (buf == null) { if (buf == null) {
return ChannelBuffers.EMPTY_BUFFER; return ChannelBuffers.EMPTY_BUFFER;
} }
@ -465,17 +466,14 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
public void afterAdd(ChannelHandlerContext ctx) throws Exception { public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Nothing to do.. // Nothing to do..
} }
public void beforeRemove(ChannelHandlerContext ctx) throws Exception { public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Nothing to do.. // Nothing to do..
} }
public void afterRemove(ChannelHandlerContext ctx) throws Exception { public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Nothing to do.. // Nothing to do..
} }
} }

View File

@ -53,6 +53,7 @@ public class CIDR6 extends CIDR {
addressEndBigInt = addressBigInt.add(ipv6CidrMaskToBaseAddress(cidrMask)).subtract(BigInteger.ONE); addressEndBigInt = addressBigInt.add(ipv6CidrMaskToBaseAddress(cidrMask)).subtract(BigInteger.ONE);
} }
@Override
public InetAddress getEndAddress() { public InetAddress getEndAddress() {
try { try {
return bigIntToIPv6Address(addressEndBigInt); return bigIntToIPv6Address(addressEndBigInt);

View File

@ -15,13 +15,14 @@
*/ */
package org.jboss.netty.handler.ipfilter; package org.jboss.netty.handler.ipfilter;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
/** /**
* This class allows to check if an IP-V4-Address is contained in a subnet.<BR> * This class allows to check if an IP-V4-Address is contained in a subnet.<BR>
* Supported Formats for the Subnets are: 1.1.1.1/255.255.255.255 or 1.1.1.1/32 (CIDR-Notation) * Supported Formats for the Subnets are: 1.1.1.1/255.255.255.255 or 1.1.1.1/32 (CIDR-Notation)
@ -141,7 +142,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
* *
* @return the integer representation * @return the integer representation
*/ */
private int toInt(InetAddress inetAddress1) { private static int toInt(InetAddress inetAddress1) {
byte[] address = inetAddress1.getAddress(); byte[] address = inetAddress1.getAddress();
int net = 0; int net = 0;
for (byte addres : address) { for (byte addres : address) {

View File

@ -58,7 +58,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
private boolean localhost; private boolean localhost;
private String pattern; private final String pattern;
/** /**
* Instantiates a new pattern rule. * Instantiates a new pattern rule.
@ -67,7 +67,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
* @param pattern the filter pattern * @param pattern the filter pattern
*/ */
public PatternRule(boolean allow, String pattern) { public PatternRule(boolean allow, String pattern) {
this.isAllowRule = allow; isAllowRule = allow;
this.pattern = pattern; this.pattern = pattern;
parse(pattern); parse(pattern);
} }
@ -78,7 +78,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
* @return the pattern * @return the pattern
*/ */
public String getPattern() { public String getPattern() {
return this.pattern; return pattern;
} }
public boolean isAllowRule() { public boolean isAllowRule() {
@ -120,7 +120,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
for (String c : acls) { for (String c : acls) {
c = c.trim(); c = c.trim();
if (c.equals("n:localhost")) { if (c.equals("n:localhost")) {
this.localhost = true; localhost = true;
} else if (c.startsWith("n:")) { } else if (c.startsWith("n:")) {
name = addRule(name, c.substring(2)); name = addRule(name, c.substring(2));
} else if (c.startsWith("i:")) { } else if (c.startsWith("i:")) {
@ -135,7 +135,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
} }
} }
private String addRule(String pattern, String rule) { private static String addRule(String pattern, String rule) {
if (rule == null || rule.length() == 0) { if (rule == null || rule.length() == 0) {
return pattern; return pattern;
} }
@ -149,7 +149,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
return pattern; return pattern;
} }
private boolean isLocalhost(InetAddress address) { private static boolean isLocalhost(InetAddress address) {
try { try {
if (address.equals(InetAddress.getLocalHost())) { if (address.equals(InetAddress.getLocalHost())) {
return true; return true;
@ -183,14 +183,14 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
return -1; return -1;
} }
PatternRule p = (PatternRule) o; PatternRule p = (PatternRule) o;
if (p.isAllowRule() && !this.isAllowRule) { if (p.isAllowRule() && !isAllowRule) {
return -1; return -1;
} }
if (this.pattern == null && p.pattern == null) { if (pattern == null && p.pattern == null) {
return 0; return 0;
} }
if (this.pattern != null) { if (pattern != null) {
return this.pattern.compareTo(p.getPattern()); return pattern.compareTo(p.getPattern());
} }
return -1; return -1;
} }

View File

@ -46,7 +46,6 @@ import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.DefaultChannelFuture; import org.jboss.netty.channel.DefaultChannelFuture;
import org.jboss.netty.channel.DownstreamMessageEvent; import org.jboss.netty.channel.DownstreamMessageEvent;
import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.jboss.netty.handler.codec.frame.FrameDecoder;
import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLogger;
@ -151,8 +150,7 @@ import org.jboss.netty.util.internal.QueueFactory;
* @apiviz.uses org.jboss.netty.handler.ssl.SslBufferPool * @apiviz.uses org.jboss.netty.handler.ssl.SslBufferPool
*/ */
public class SslHandler extends FrameDecoder public class SslHandler extends FrameDecoder
implements ChannelDownstreamHandler, implements ChannelDownstreamHandler {
LifeCycleAwareChannelHandler {
private static final InternalLogger logger = private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SslHandler.class); InternalLoggerFactory.getInstance(SslHandler.class);
@ -1219,14 +1217,17 @@ public class SslHandler extends FrameDecoder
} }
} }
@Override
public void beforeAdd(ChannelHandlerContext ctx) throws Exception { public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx; this.ctx = ctx;
} }
@Override
public void afterAdd(ChannelHandlerContext ctx) throws Exception { public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Unused // Unused
} }
@Override
public void beforeRemove(ChannelHandlerContext ctx) throws Exception { public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Unused // Unused
} }
@ -1234,6 +1235,7 @@ public class SslHandler extends FrameDecoder
/** /**
* Fail all pending writes which we were not able to flush out * Fail all pending writes which we were not able to flush out
*/ */
@Override
public void afterRemove(ChannelHandlerContext ctx) throws Exception { public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// there is no need for synchronization here as we do not receive downstream events anymore // there is no need for synchronization here as we do not receive downstream events anymore

View File

@ -347,14 +347,14 @@ public abstract class AbstractTrafficShapingHandler extends
* @return the time that should be necessary to wait to respect limit. Can * @return the time that should be necessary to wait to respect limit. Can
* be negative time * be negative time
*/ */
private long getTimeToWait(long limit, long bytes, long lastTime, private static long getTimeToWait(long limit, long bytes, long lastTime,
long curtime) { long curtime) {
long interval = curtime - lastTime; long interval = curtime - lastTime;
if (interval == 0) { if (interval == 0) {
// Time is too short, so just lets continue // Time is too short, so just lets continue
return 0; return 0;
} }
return ((bytes * 1000 / limit - interval) / 10) * 10; return (bytes * 1000 / limit - interval) / 10 * 10;
} }
@Override @Override

View File

@ -25,13 +25,13 @@
* *
* <P>Two classes implement this behavior:<br> * <P>Two classes implement this behavior:<br>
* <ul> * <ul>
* <li> <tt>{@link TrafficCounter}</tt>: this class implements the counters needed by the handlers. * <li> <tt>{@link org.jboss.netty.handler.traffic.TrafficCounter}</tt>: this class implements the counters needed by the handlers.
* It can be accessed to get some extra information like the read or write bytes since last check, the read and write * It can be accessed to get some extra information like the read or write bytes since last check, the read and write
* bandwidth from last check...</li><br><br> * bandwidth from last check...</li><br><br>
* *
* <li> <tt>{@link AbstractTrafficShapingHandler}</tt>: this abstract class implements the kernel * <li> <tt>{@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}</tt>: this abstract class implements the kernel
* of the traffic shaping. It could be extended to fit your needs. Two classes are proposed as default * of the traffic shaping. It could be extended to fit your needs. Two classes are proposed as default
* implementations: see {@link ChannelTrafficShapingHandler} and see {@link GlobalTrafficShapingHandler} * implementations: see {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} and see {@link org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler}
* respectively for Channel traffic shaping and Global traffic shaping.</li><br><br> * respectively for Channel traffic shaping and Global traffic shaping.</li><br><br>
* *
* The insertion in the pipeline of one of those handlers can be wherever you want, but * The insertion in the pipeline of one of those handlers can be wherever you want, but
@ -62,15 +62,15 @@
* [Global or per Channel] [Write or Read] Limitation in byte/s.</li><br> * [Global or per Channel] [Write or Read] Limitation in byte/s.</li><br>
* A value of <tt>0</tt> * A value of <tt>0</tt>
* stands for no limitation, so the traffic shaping is deactivate (on what you specified).<br> * stands for no limitation, so the traffic shaping is deactivate (on what you specified).<br>
* You can either change those values with the method <tt>configure</tt> in {@link AbstractTrafficShapingHandler}.<br> * You can either change those values with the method <tt>configure</tt> in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}.<br>
* <br> * <br>
* *
* <li>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms * <li>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms
* for efficiency reasons) or a high value (let say 24H in millisecond is huge enough to not get the problem) * for efficiency reasons) or a high value (let say 24H in millisecond is huge enough to not get the problem)
* or even using <tt>0</tt> which means no computation will be done.</li><br> * or even using <tt>0</tt> which means no computation will be done.</li><br>
* If you want to do anything with this statistics, just override the <tt>doAccounting</tt> method.<br> * If you want to do anything with this statistics, just override the <tt>doAccounting</tt> method.<br>
* This interval can be changed either from the method <tt>configure</tt> in {@link AbstractTrafficShapingHandler} * This interval can be changed either from the method <tt>configure</tt> in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}
* or directly using the method <tt>configure</tt> of {@link TrafficCounter}.<br><br> * or directly using the method <tt>configure</tt> of {@link org.jboss.netty.handler.traffic.TrafficCounter}.<br><br>
* *
* </ul></P><br><br> * </ul></P><br><br>
* *
@ -81,8 +81,8 @@
* <tt>pipeline.addLast("XXXXX_TRAFFIC_SHAPING", myHandler);</tt><br> * <tt>pipeline.addLast("XXXXX_TRAFFIC_SHAPING", myHandler);</tt><br>
* <tt>...</tt><br> * <tt>...</tt><br>
* <tt>pipeline.addLast("MemoryExecutor",new ExecutionHandler(memoryAwareThreadPoolExecutor));</tt><br><br> * <tt>pipeline.addLast("MemoryExecutor",new ExecutionHandler(memoryAwareThreadPoolExecutor));</tt><br><br>
* <P>Note that a new {@link ChannelTrafficShapingHandler} must be created for each new channel, * <P>Note that a new {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} must be created for each new channel,
* but only one {@link GlobalTrafficShapingHandler} must be created for all channels.</P> * but only one {@link org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler} must be created for all channels.</P>
* *
* <P>Note also that you can create different GlobalTrafficShapingHandler if you want to separate classes of * <P>Note also that you can create different GlobalTrafficShapingHandler if you want to separate classes of
* channels (for instance either from business point of view or from bind address point of view).</P> * channels (for instance either from business point of view or from bind address point of view).</P>

View File

@ -20,16 +20,16 @@ import java.util.concurrent.Executor;
import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory; import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
public class NioNioDatagramTest extends AbstractDatagramTest{ public class NioNioDatagramTest extends AbstractDatagramTest {
@Override @Override
protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) { protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor); return new NioDatagramChannelFactory(executor, null);
} }
@Override @Override
protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) { protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor); return new NioDatagramChannelFactory(executor, null);
} }
} }

View File

@ -24,7 +24,7 @@ public class NioOioDatagramTest extends AbstractDatagramTest{
@Override @Override
protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) { protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor); return new NioDatagramChannelFactory(executor, null);
} }

View File

@ -24,7 +24,7 @@ public class OioNioDatagramTest extends AbstractDatagramTest{
@Override @Override
protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) { protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor); return new NioDatagramChannelFactory(executor, null);
} }
@Override @Override

View File

@ -65,12 +65,15 @@ public class IpFilterRuleTest extends TestCase {
} }
public void sendDownstream(ChannelEvent e) { public void sendDownstream(ChannelEvent e) {
// NOOP
} }
public void sendUpstream(ChannelEvent e) { public void sendUpstream(ChannelEvent e) {
// NOOP
} }
public void setAttachment(Object attachment) { public void setAttachment(Object attachment) {
// NOOP
} }
}, new UpstreamMessageEvent(new Channel() { }, new UpstreamMessageEvent(new Channel() {
@ -176,7 +179,7 @@ public class IpFilterRuleTest extends TestCase {
} }
public void setAttachment(Object attachment) { public void setAttachment(Object attachment) {
// NOOP
} }
}, h, addr), addr); }, h, addr), addr);