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() {
DatagramChannelFactory f =
new NioDatagramChannelFactory(Executors.newCachedThreadPool());
new NioDatagramChannelFactory(Executors.newCachedThreadPool(), null);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);

View File

@ -16,7 +16,6 @@
package org.jboss.netty.example.qotm;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
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.FixedReceiveBufferSizePredictorFactory;
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.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
@ -45,7 +45,7 @@ public class QuoteOfTheMomentServer {
public void run() {
DatagramChannelFactory f =
new NioDatagramChannelFactory(Executors.newCachedThreadPool());
new NioDatagramChannelFactory((ProtocolFamily) null);
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.MessageEvent;
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.
@ -265,7 +266,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
}
}
}
}
@ -369,7 +370,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
/**
* Gets called on {@link #channelDisconnected(ChannelHandlerContext, ChannelStateEvent)} and {@link #channelClosed(ChannelHandlerContext, ChannelStateEvent)}
*
*
*/
protected void cleanup(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
@ -410,12 +411,12 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
return factory.getBuffer(Math.max(minimumCapacity, 256));
}
/**
* Replace this {@link FrameDecoder} in the {@link ChannelPipeline} with the given {@link ChannelHandler}. All
* Replace this {@link FrameDecoder} in the {@link ChannelPipeline} with the given {@link ChannelHandler}. All
* remaining bytes in the {@link ChannelBuffer} will get send to the new {@link ChannelHandler} that was used
* as replacement
*
*
*/
public void replace(String handlerName, ChannelHandler handler) {
if (ctx == null) {
@ -423,7 +424,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
}
ChannelPipeline pipeline = ctx.getPipeline();
pipeline.addAfter(ctx.getName(), handlerName, handler);
try {
if (cumulation != null) {
Channels.fireMessageReceived(ctx, cumulation.readBytes(actualReadableBytes()));
@ -431,9 +432,9 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
} finally {
pipeline.remove(this);
}
}
/**
* Returns the actual number of readable bytes in the internal cumulative
* buffer of this decoder. You usually do not need to rely on this value
@ -443,7 +444,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
protected int actualReadableBytes() {
return internalBuffer().readableBytes();
}
/**
@ -452,7 +453,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
* Use it only when you must use it at your own risk.
*/
protected ChannelBuffer internalBuffer() {
ChannelBuffer buf = this.cumulation;
ChannelBuffer buf = cumulation;
if (buf == null) {
return ChannelBuffers.EMPTY_BUFFER;
}
@ -465,17 +466,14 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Nothing to do..
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Nothing to do..
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Nothing to do..
}
}

View File

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

View File

@ -15,13 +15,14 @@
*/
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.UnknownHostException;
import java.util.StringTokenizer;
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>
* Supported Formats for the Subnets are: 1.1.1.1/255.255.255.255 or 1.1.1.1/32 (CIDR-Notation)
@ -42,10 +43,10 @@ import java.util.Vector;
* where inetAddress is 192.168.1.0 and inetAddress2 is 192.168.1.123<BR>
*/
public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(IpV4Subnet.class);
private static final int SUBNET_MASK = 0x80000000;
private static final int BYTE_ADDRESS_MASK = 0xFF;
@ -141,7 +142,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
*
* @return the integer representation
*/
private int toInt(InetAddress inetAddress1) {
private static int toInt(InetAddress inetAddress1) {
byte[] address = inetAddress1.getAddress();
int net = 0;
for (byte addres : address) {
@ -230,7 +231,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
IpV4Subnet ipV4Subnet = (IpV4Subnet) o;
return ipV4Subnet.subnet == subnet && ipV4Subnet.cidrMask == cidrMask;
}
@Override
public int hashCode() {
return subnet;

View File

@ -58,7 +58,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
private boolean localhost;
private String pattern;
private final String pattern;
/**
* Instantiates a new pattern rule.
@ -67,7 +67,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
* @param pattern the filter pattern
*/
public PatternRule(boolean allow, String pattern) {
this.isAllowRule = allow;
isAllowRule = allow;
this.pattern = pattern;
parse(pattern);
}
@ -78,7 +78,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
* @return the pattern
*/
public String getPattern() {
return this.pattern;
return pattern;
}
public boolean isAllowRule() {
@ -120,7 +120,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
for (String c : acls) {
c = c.trim();
if (c.equals("n:localhost")) {
this.localhost = true;
localhost = true;
} else if (c.startsWith("n:")) {
name = addRule(name, c.substring(2));
} 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) {
return pattern;
}
@ -149,7 +149,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
return pattern;
}
private boolean isLocalhost(InetAddress address) {
private static boolean isLocalhost(InetAddress address) {
try {
if (address.equals(InetAddress.getLocalHost())) {
return true;
@ -183,14 +183,14 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
return -1;
}
PatternRule p = (PatternRule) o;
if (p.isAllowRule() && !this.isAllowRule) {
if (p.isAllowRule() && !isAllowRule) {
return -1;
}
if (this.pattern == null && p.pattern == null) {
if (pattern == null && p.pattern == null) {
return 0;
}
if (this.pattern != null) {
return this.pattern.compareTo(p.getPattern());
if (pattern != null) {
return pattern.compareTo(p.getPattern());
}
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.DownstreamMessageEvent;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
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
*/
public class SslHandler extends FrameDecoder
implements ChannelDownstreamHandler,
LifeCycleAwareChannelHandler {
implements ChannelDownstreamHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SslHandler.class);
@ -720,7 +718,7 @@ public class SslHandler extends FrameDecoder
outNetBuf.flip();
int remaining = outNetBuf.remaining();
msg = ctx.getChannel().getConfig().getBufferFactory().getBuffer(remaining);
// Transfer the bytes to the new ChannelBuffer using some safe method that will also
// work with "non" heap buffers
//
@ -865,7 +863,7 @@ public class SslHandler extends FrameDecoder
outNetBuf.flip();
ChannelBuffer msg = ctx.getChannel().getConfig().getBufferFactory().getBuffer(outNetBuf.remaining());
// Transfer the bytes to the new ChannelBuffer using some safe method that will also
// work with "non" heap buffers
//
@ -1219,14 +1217,17 @@ public class SslHandler extends FrameDecoder
}
}
@Override
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
}
@Override
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Unused
}
@Override
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
@ -1234,6 +1235,7 @@ public class SslHandler extends FrameDecoder
/**
* Fail all pending writes which we were not able to flush out
*/
@Override
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// there is no need for synchronization here as we do not receive downstream events anymore
@ -1281,12 +1283,12 @@ public class SslHandler extends FrameDecoder
if (!future.isSuccess()) {
Channels.fireExceptionCaught(future.getChannel(), future.getCause());
} else {
// Send the event upstream after the handshake was completed without an error.
// Send the event upstream after the handshake was completed without an error.
//
// See https://github.com/netty/netty/issues/358
ctx.sendUpstream(e);
}
}
});
} else {

View File

@ -93,7 +93,7 @@ public abstract class AbstractTrafficShapingHandler extends
* used in releaseExternalResources() to cancel the timer
*/
private volatile Timeout timeout;
/**
* Limit in B/s to apply to write
*/
@ -347,14 +347,14 @@ public abstract class AbstractTrafficShapingHandler extends
* @return the time that should be necessary to wait to respect limit. Can
* 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 interval = curtime - lastTime;
if (interval == 0) {
// Time is too short, so just lets continue
return 0;
}
return ((bytes * 1000 / limit - interval) / 10) * 10;
return (bytes * 1000 / limit - interval) / 10 * 10;
}
@Override

View File

@ -25,13 +25,13 @@
*
* <P>Two classes implement this behavior:<br>
* <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
* 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
* 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>
*
* 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>
* A value of <tt>0</tt>
* 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>
*
* <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)
* 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>
* This interval can be changed either from the method <tt>configure</tt> in {@link AbstractTrafficShapingHandler}
* or directly using the method <tt>configure</tt> of {@link TrafficCounter}.<br><br>
* 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 org.jboss.netty.handler.traffic.TrafficCounter}.<br><br>
*
* </ul></P><br><br>
*
@ -81,8 +81,8 @@
* <tt>pipeline.addLast("XXXXX_TRAFFIC_SHAPING", myHandler);</tt><br>
* <tt>...</tt><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,
* but only one {@link GlobalTrafficShapingHandler} must be created for all channels.</P>
* <P>Note that a new {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} must be created for each new channel,
* 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
* 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;
public class NioNioDatagramTest extends AbstractDatagramTest{
public class NioNioDatagramTest extends AbstractDatagramTest {
@Override
protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor);
return new NioDatagramChannelFactory(executor, null);
}
@Override
protected DatagramChannelFactory newClientSocketChannelFactory(Executor executor) {
return new NioDatagramChannelFactory(executor);
return new NioDatagramChannelFactory(executor, null);
}
}

View File

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

View File

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

View File

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