Fix compiler warnings

This commit is contained in:
Trustin Lee 2013-04-04 16:31:41 +09:00
parent 4505e7f1b3
commit 6dfa455f9e
3 changed files with 20 additions and 10 deletions

View File

@ -15,14 +15,14 @@
*/
package io.netty.handler.codec.compression;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.JZlib;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.Deflater;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@ -380,7 +380,7 @@ public class JZlibEncoder extends ZlibEncoder {
// Write the ADLER32 checksum (stream footer).
int resultCode = z.deflate(JZlib.Z_FINISH);
if (resultCode != JZlib.Z_OK && resultCode != JZlib.Z_STREAM_END) {
future.setFailure(ZlibUtil.exception(z, "compression failure", resultCode));
future.setFailure(ZlibUtil.deflaterException(z, "compression failure", resultCode));
return future;
} else if (z.next_out_index != 0) {
footer = Unpooled.wrappedBuffer(out, 0, z.next_out_index);

View File

@ -15,21 +15,29 @@
*/
package io.netty.handler.codec.compression;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.Inflater;
import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.ZStream;
/**
* Utility methods used by {@link JZlibEncoder} and {@link JZlibDecoder}.
*/
final class ZlibUtil {
static void fail(ZStream z, String message, int resultCode) {
throw exception(z, message, resultCode);
static void fail(Inflater z, String message, int resultCode) {
throw inflaterException(z, message, resultCode);
}
static CompressionException exception(ZStream z, String message, int resultCode) {
return new CompressionException(message + " (" + resultCode + ')' +
(z.msg != null? ": " + z.msg : ""));
static void fail(Deflater z, String message, int resultCode) {
throw deflaterException(z, message, resultCode);
}
static CompressionException inflaterException(Inflater z, String message, int resultCode) {
return new CompressionException(message + " (" + resultCode + ')' + (z.msg != null? ": " + z.msg : ""));
}
static CompressionException deflaterException(Deflater z, String message, int resultCode) {
return new CompressionException(message + " (" + resultCode + ')' + (z.msg != null? ": " + z.msg : ""));
}
static JZlib.WrapperType convertWrapperType(ZlibWrapper wrapper) {

View File

@ -98,7 +98,8 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
}
@Override
public Promise<V> addListener(GenericFutureListener<? extends Future<V>> listener) {
@SuppressWarnings("unchecked")
public Promise<V> addListener(GenericFutureListener <? extends Future<V>> listener) {
if (listener == null) {
throw new NullPointerException("listener");
}
@ -459,6 +460,7 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
state -= 0x10000000000L;
}
@SuppressWarnings("unchecked")
private void notifyListeners() {
// This method doesn't need synchronization because:
// 1) This method is always called after synchronized (this) block.