Fix more inspection warnings + compilation errors
This commit is contained in:
parent
bcc088b3d7
commit
c09f8c147d
@ -39,32 +39,33 @@ final class CombinedIterator<E> implements Iterator<E> {
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
boolean hasNext = currentIterator.hasNext();
|
||||
if (hasNext) {
|
||||
for (;;) {
|
||||
if (currentIterator.hasNext()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentIterator == i1) {
|
||||
currentIterator = i2;
|
||||
return hasNext();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public E next() {
|
||||
for (;;) {
|
||||
try {
|
||||
E e = currentIterator.next();
|
||||
return e;
|
||||
} catch (NoSuchElementException e) {
|
||||
if (currentIterator == i1) {
|
||||
currentIterator = i2;
|
||||
return next();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
currentIterator.remove();
|
||||
|
@ -53,7 +53,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
private final ChannelFutureListener childListener = new ChannelFutureListener() {
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
boolean success = future.isSuccess();
|
||||
boolean callSetDone = false;
|
||||
boolean callSetDone;
|
||||
synchronized (DefaultChannelGroupFuture.this) {
|
||||
if (success) {
|
||||
successCount ++;
|
||||
|
@ -585,6 +585,8 @@ abstract class AbstractNioWorker implements Worker, ExternalResourceReleasable {
|
||||
buf.release();
|
||||
channel.currentWriteEvent = null;
|
||||
channel.currentWriteBuffer = null;
|
||||
// Mark the event object for garbage collection.
|
||||
//noinspection UnusedAssignment
|
||||
evt = null;
|
||||
buf = null;
|
||||
future.setSuccess();
|
||||
@ -609,7 +611,10 @@ abstract class AbstractNioWorker implements Worker, ExternalResourceReleasable {
|
||||
}
|
||||
channel.currentWriteEvent = null;
|
||||
channel.currentWriteBuffer = null;
|
||||
// Mark the event object for garbage collection.
|
||||
//noinspection UnusedAssignment
|
||||
buf = null;
|
||||
//noinspection UnusedAssignment
|
||||
evt = null;
|
||||
future.setFailure(t);
|
||||
if (iothread) {
|
||||
@ -762,6 +767,8 @@ abstract class AbstractNioWorker implements Worker, ExternalResourceReleasable {
|
||||
channel.currentWriteBuffer.release();
|
||||
channel.currentWriteBuffer = null;
|
||||
channel.currentWriteEvent = null;
|
||||
// Mark the event object for garbage collection.
|
||||
//noinspection UnusedAssignment
|
||||
evt = null;
|
||||
future.setFailure(cause);
|
||||
fireExceptionCaught = true;
|
||||
|
@ -15,7 +15,12 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
@ -28,12 +33,7 @@ import java.nio.channels.Selector;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
/**
|
||||
* A class responsible for registering channels with {@link Selector}.
|
||||
@ -328,7 +328,10 @@ public class NioDatagramWorker extends AbstractNioWorker {
|
||||
ChannelFuture future = evt.getFuture();
|
||||
channel.currentWriteEvent = null;
|
||||
channel.currentWriteBuffer = null;
|
||||
// Mark the event object for garbage collection.
|
||||
//noinspection UnusedAssignment
|
||||
buf = null;
|
||||
//noinspection UnusedAssignment
|
||||
evt = null;
|
||||
future.setFailure(t);
|
||||
fireExceptionCaught(channel, t);
|
||||
|
@ -55,7 +55,7 @@ final class NioProviderMetadata {
|
||||
static final int CONSTRAINT_LEVEL;
|
||||
|
||||
static {
|
||||
int constraintLevel = -1;
|
||||
int constraintLevel;
|
||||
|
||||
// Use the system property if possible.
|
||||
constraintLevel = SystemPropertyUtil.getInt(CONSTRAINT_LEVEL_PROPERTY, -1);
|
||||
|
@ -15,7 +15,10 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.oio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.DefaultFileRegion;
|
||||
import org.jboss.netty.channel.FileRegion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -26,10 +29,7 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.DefaultFileRegion;
|
||||
import org.jboss.netty.channel.FileRegion;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
class OioWorker extends AbstractOioWorker<OioSocketChannel> {
|
||||
|
||||
@ -102,7 +102,7 @@ class OioWorker extends AbstractOioWorker<OioSocketChannel> {
|
||||
synchronized (out) {
|
||||
WritableByteChannel bchannel = Channels.newChannel(out);
|
||||
|
||||
long i = 0;
|
||||
long i;
|
||||
while ((i = fr.transferTo(bchannel, length)) > 0) {
|
||||
length += i;
|
||||
if (length >= fr.getCount()) {
|
||||
|
@ -202,7 +202,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
}
|
||||
responseContent.append('o');
|
||||
// example of reading chunk by chunk (minimize memory usage due to Factory)
|
||||
readHttpDataChunkByChunk(e.getChannel());
|
||||
readHttpDataChunkByChunk();
|
||||
// example of reading only if at the end
|
||||
if (chunk.isLast()) {
|
||||
readHttpDataAllReceive(e.getChannel());
|
||||
@ -216,7 +216,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* Example of reading all InterfaceHttpData from finished transfer
|
||||
*/
|
||||
private void readHttpDataAllReceive(Channel channel) {
|
||||
List<InterfaceHttpData> datas = null;
|
||||
List<InterfaceHttpData> datas;
|
||||
try {
|
||||
datas = decoder.getBodyHttpDatas();
|
||||
} catch (NotEnoughDataDecoderException e1) {
|
||||
@ -237,7 +237,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
||||
* Example of reading request by chunk and getting values from chunk to
|
||||
* chunk
|
||||
*/
|
||||
private void readHttpDataChunkByChunk(Channel channel) {
|
||||
private void readHttpDataChunkByChunk() {
|
||||
try {
|
||||
while (decoder.hasNext()) {
|
||||
InterfaceHttpData data = decoder.next();
|
||||
|
@ -15,17 +15,16 @@
|
||||
*/
|
||||
package org.jboss.netty.example.securechat;
|
||||
|
||||
import java.security.KeyStore;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import org.jboss.netty.handler.ssl.SslHandler;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
import org.jboss.netty.handler.ssl.SslHandler;
|
||||
import java.security.KeyStore;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* Creates a bogus {@link SSLContext}. A client-side context created by this
|
||||
@ -62,8 +61,8 @@ public final class SecureChatSslContextFactory {
|
||||
algorithm = "SunX509";
|
||||
}
|
||||
|
||||
SSLContext serverContext = null;
|
||||
SSLContext clientContext = null;
|
||||
SSLContext serverContext;
|
||||
SSLContext clientContext;
|
||||
try {
|
||||
KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(SecureChatKeyStore.asInputStream(),
|
||||
|
@ -296,9 +296,9 @@ public final class Base64 {
|
||||
|
||||
byte[] b4 = new byte[4];
|
||||
int b4Posn = 0;
|
||||
int i = 0;
|
||||
byte sbiCrop = 0;
|
||||
byte sbiDecode = 0;
|
||||
int i;
|
||||
byte sbiCrop;
|
||||
byte sbiDecode;
|
||||
for (i = off; i < off + len; i ++) {
|
||||
sbiCrop = (byte) (src.getByte(i) & 0x7f); // Only the low seven bits
|
||||
sbiDecode = DECODABET[sbiCrop];
|
||||
|
@ -71,7 +71,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
* @return a new Temp File from getDiskFilename(), default prefix, postfix and baseDirectory
|
||||
*/
|
||||
private File tempFile() throws IOException {
|
||||
String newpostfix = null;
|
||||
String newpostfix;
|
||||
String diskFilename = getDiskFilename();
|
||||
if (diskFilename != null) {
|
||||
newpostfix = '_' + diskFilename;
|
||||
|
@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -24,10 +28,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Abstract Memory HttpData implementation
|
||||
*/
|
||||
@ -148,7 +148,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
return "";
|
||||
}
|
||||
if (encoding == null) {
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
encoding = HttpConstants.DEFAULT_CHARSET;
|
||||
}
|
||||
return channelBuffer.toString(encoding);
|
||||
}
|
||||
|
@ -433,8 +433,8 @@ public class HttpPostRequestDecoder {
|
||||
private void parseBodyAttributesStandard() throws ErrorDataDecoderException {
|
||||
int firstpos = undecodedChunk.readerIndex();
|
||||
int currentpos = firstpos;
|
||||
int equalpos = firstpos;
|
||||
int ampersandpos = firstpos;
|
||||
int equalpos;
|
||||
int ampersandpos;
|
||||
if (currentStatus == MultiPartStatus.NOTSTARTED) {
|
||||
currentStatus = MultiPartStatus.DISPOSITION;
|
||||
}
|
||||
@ -486,7 +486,6 @@ public class HttpPostRequestDecoder {
|
||||
contRead = false;
|
||||
} else {
|
||||
// Error
|
||||
contRead = false;
|
||||
throw new ErrorDataDecoderException("Bad end of line");
|
||||
}
|
||||
} else {
|
||||
@ -550,7 +549,7 @@ public class HttpPostRequestDecoder {
|
||||
* other errors
|
||||
*/
|
||||
private void parseBodyAttributes() throws ErrorDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -559,8 +558,8 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
int firstpos = undecodedChunk.readerIndex();
|
||||
int currentpos = firstpos;
|
||||
int equalpos = firstpos;
|
||||
int ampersandpos = firstpos;
|
||||
int equalpos;
|
||||
int ampersandpos;
|
||||
if (currentStatus == MultiPartStatus.NOTSTARTED) {
|
||||
currentStatus = MultiPartStatus.DISPOSITION;
|
||||
}
|
||||
@ -616,7 +615,6 @@ public class HttpPostRequestDecoder {
|
||||
} else {
|
||||
// Error
|
||||
sao.setReadPosition(0);
|
||||
contRead = false;
|
||||
throw new ErrorDataDecoderException("Bad end of line");
|
||||
}
|
||||
} else {
|
||||
@ -843,7 +841,7 @@ public class HttpPostRequestDecoder {
|
||||
* @throws NotEnoughDataDecoderException
|
||||
*/
|
||||
void skipControlCharacters() throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e) {
|
||||
@ -945,7 +943,7 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
String[] contents = splitMultipartHeader(newline);
|
||||
if (contents[0].equalsIgnoreCase(HttpPostBodyUtil.CONTENT_DISPOSITION)) {
|
||||
boolean checkSecondArg = false;
|
||||
boolean checkSecondArg;
|
||||
if (currentStatus == MultiPartStatus.DISPOSITION) {
|
||||
checkSecondArg = contents[1]
|
||||
.equalsIgnoreCase(HttpPostBodyUtil.FORM_DATA);
|
||||
@ -1249,7 +1247,7 @@ public class HttpPostRequestDecoder {
|
||||
* reset the readerInder to the previous value
|
||||
*/
|
||||
private String readLine() throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1385,7 +1383,7 @@ public class HttpPostRequestDecoder {
|
||||
* reset the readerInder to the previous value
|
||||
*/
|
||||
private String readDelimiter(String delimiter) throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1583,7 +1581,7 @@ public class HttpPostRequestDecoder {
|
||||
*/
|
||||
private void readFileUploadByteMultipart(String delimiter)
|
||||
throws NotEnoughDataDecoderException, ErrorDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1595,7 +1593,7 @@ public class HttpPostRequestDecoder {
|
||||
boolean newLine = true;
|
||||
int index = 0;
|
||||
int lastrealpos = sao.pos;
|
||||
int lastPosition = undecodedChunk.readerIndex();
|
||||
int lastPosition;
|
||||
boolean found = false;
|
||||
|
||||
while (sao.pos < sao.limit) {
|
||||
@ -1778,7 +1776,7 @@ public class HttpPostRequestDecoder {
|
||||
*/
|
||||
private void loadFieldMultipart(String delimiter)
|
||||
throws NotEnoughDataDecoderException, ErrorDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1790,7 +1788,7 @@ public class HttpPostRequestDecoder {
|
||||
// found the decoder limit
|
||||
boolean newLine = true;
|
||||
int index = 0;
|
||||
int lastPosition = undecodedChunk.readerIndex();
|
||||
int lastPosition;
|
||||
int lastrealpos = sao.pos;
|
||||
boolean found = false;
|
||||
|
||||
@ -1880,8 +1878,7 @@ public class HttpPostRequestDecoder {
|
||||
*/
|
||||
private static String cleanString(String field) {
|
||||
StringBuilder sb = new StringBuilder(field.length());
|
||||
int i = 0;
|
||||
for (i = 0; i < field.length(); i ++) {
|
||||
for (int i = 0; i < field.length(); i ++) {
|
||||
char nextChar = field.charAt(i);
|
||||
if (nextChar == HttpConstants.COLON) {
|
||||
sb.append(HttpConstants.SP);
|
||||
@ -1983,7 +1980,7 @@ public class HttpPostRequestDecoder {
|
||||
valueEnd = HttpPostBodyUtil.findEndOfString(sb);
|
||||
headers.add(sb.substring(nameStart, nameEnd));
|
||||
String svalue = sb.substring(valueStart, valueEnd);
|
||||
String[] values = null;
|
||||
String[] values;
|
||||
if (svalue.indexOf(';') >= 0) {
|
||||
values = StringUtil.split(svalue, ';');
|
||||
} else {
|
||||
|
@ -432,7 +432,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
// previously a data field so CRLF
|
||||
internal.addValue("\r\n");
|
||||
}
|
||||
boolean localMixed = false;
|
||||
boolean localMixed;
|
||||
if (duringMixedMode) {
|
||||
if (currentFileUpload != null &&
|
||||
currentFileUpload.getName().equals(fileUpload.getName())) {
|
||||
@ -873,7 +873,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
isLastChunkSent = true;
|
||||
return new DefaultHttpChunk(ChannelBuffers.EMPTY_BUFFER);
|
||||
}
|
||||
ChannelBuffer buffer = null;
|
||||
ChannelBuffer buffer;
|
||||
int size = HttpPostBodyUtil.chunkSize;
|
||||
// first test if previous buffer is not empty
|
||||
if (currentBuffer != null) {
|
||||
|
@ -53,8 +53,6 @@
|
||||
|
||||
package org.jboss.netty.handler.codec.http.websocketx;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
@ -64,6 +62,8 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Encodes a web socket frame into wire protocol version 8 format. This code was forked from <a
|
||||
@ -173,7 +173,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
||||
int counter = 0;
|
||||
while (data.readableBytes() > 0) {
|
||||
byte byteData = data.readByte();
|
||||
body.writeByte(byteData ^ mask[+counter++ % 4]);
|
||||
body.writeByte(byteData ^ mask[counter++ % 4]);
|
||||
}
|
||||
} else {
|
||||
body = data;
|
||||
|
@ -458,7 +458,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
this.cumulation = cumulation = newCumulationBuffer(ctx, bytesToPreserve);
|
||||
cumulation.writeBytes(input, checkpoint, bytesToPreserve);
|
||||
} else {
|
||||
this.cumulation = cumulation = input.slice(checkpoint, bytesToPreserve);
|
||||
this.cumulation = input.slice(checkpoint, bytesToPreserve);
|
||||
}
|
||||
} else if (checkpoint == 0) {
|
||||
if (copy) {
|
||||
@ -474,7 +474,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
this.cumulation = cumulation = newCumulationBuffer(ctx, input.readableBytes());
|
||||
cumulation.writeBytes(input);
|
||||
} else {
|
||||
this.cumulation = cumulation = input;
|
||||
this.cumulation = input;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -251,12 +251,12 @@ final class SpdyCodecUtil {
|
||||
".1statusversionurl ";
|
||||
static final byte[] SPDY2_DICT;
|
||||
static {
|
||||
byte[] SPDY2_DICT_ = null;
|
||||
byte[] SPDY2_DICT_;
|
||||
|
||||
try {
|
||||
SPDY2_DICT_ = SPDY2_DICT_S.getBytes("US-ASCII");
|
||||
// dictionary is null terminated
|
||||
SPDY2_DICT_[SPDY2_DICT_.length - 1] = (byte) 0;
|
||||
SPDY2_DICT_[SPDY2_DICT_.length - 1] = 0;
|
||||
} catch (Exception e) {
|
||||
SPDY2_DICT_ = new byte[1];
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public class SpdyFrameEncoder implements ChannelDownstreamHandler {
|
||||
frame.writeInt(numEntries);
|
||||
for (Integer ID: IDs) {
|
||||
int id = ID.intValue();
|
||||
byte ID_flags = (byte) 0;
|
||||
byte ID_flags = 0;
|
||||
if (spdySettingsFrame.isPersistValue(id)) {
|
||||
ID_flags |= SPDY_SETTINGS_PERSIST_VALUE;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private ChannelFuture getContentFuture(
|
||||
private static ChannelFuture getContentFuture(
|
||||
ChannelHandlerContext ctx, MessageEvent e, int streamID, HttpMessage httpMessage) {
|
||||
if (httpMessage.getContent().readableBytes() == 0) {
|
||||
return e.getFuture();
|
||||
|
@ -15,15 +15,15 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||
import org.jboss.netty.handler.codec.http.HttpMessage;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* {@link SimpleChannelHandler} that takes care of adding the right streamId to the
|
||||
* {@link HttpResponse} if one is not present. This makes it possible to just re-use plan handlers current used
|
||||
@ -54,7 +54,7 @@ public class SpdyHttpResponseStreamIdHandler extends SimpleChannelHandler {
|
||||
if (e.getMessage() instanceof HttpResponse) {
|
||||
HttpResponse response = (HttpResponse) e.getMessage();
|
||||
Integer id = ids.poll();
|
||||
if (id != null && id != NO_ID && !response.containsHeader(SpdyHttpHeaders.Names.STREAM_ID)) {
|
||||
if (id != null && id.intValue() != NO_ID && !response.containsHeader(SpdyHttpHeaders.Names.STREAM_ID)) {
|
||||
SpdyHttpHeaders.setStreamId(response, id);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,13 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.execution;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelState;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.util.ObjectSizeEstimator;
|
||||
import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
@ -26,13 +33,6 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelState;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.util.ObjectSizeEstimator;
|
||||
import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
|
||||
|
||||
/**
|
||||
* A {@link MemoryAwareThreadPoolExecutor} which makes sure the events from the
|
||||
* same {@link Channel} are executed sequentially.
|
||||
@ -294,7 +294,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
|
||||
}
|
||||
|
||||
public void run() {
|
||||
boolean acquired = false;
|
||||
boolean acquired;
|
||||
|
||||
// check if its already running by using CAS. If so just return here. So in the worst case the thread
|
||||
// is executed and do nothing
|
||||
|
@ -93,7 +93,7 @@ public abstract class CIDR implements Comparable<CIDR> {
|
||||
String addrString = cidr.substring(0, p);
|
||||
String maskString = cidr.substring(p + 1);
|
||||
InetAddress addr = addressStringToInet(addrString);
|
||||
int mask = 0;
|
||||
int mask;
|
||||
if (maskString.indexOf('.') < 0) {
|
||||
mask = parseInt(maskString, -1);
|
||||
} else {
|
||||
|
@ -131,7 +131,7 @@ public class CIDR4 extends CIDR {
|
||||
* IPv6 address.
|
||||
*/
|
||||
private static int ipv4AddressToInt(InetAddress addr) {
|
||||
byte[] address = null;
|
||||
byte[] address;
|
||||
if (addr instanceof Inet6Address) {
|
||||
address = getIpV4FromIpV6((Inet6Address) addr);
|
||||
} else {
|
||||
|
@ -152,7 +152,7 @@ public class CIDR6 extends CIDR {
|
||||
} else {
|
||||
// copy the address into a 16 byte array, zero-filled.
|
||||
int p = 16 - b.length;
|
||||
System.arraycopy(b, 0, a, p + 0, b.length);
|
||||
System.arraycopy(b, 0, a, p, b.length);
|
||||
}
|
||||
return InetAddress.getByAddress(a);
|
||||
}
|
||||
|
@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.ipfilter;
|
||||
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
@ -22,10 +26,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* Implementation of Filter of IP based on ALLOW and DENY rules.<br>
|
||||
* <br><br>
|
||||
@ -245,7 +245,7 @@ public class IpFilterRuleHandler extends IpFilteringHandlerImpl {
|
||||
}
|
||||
InetAddress inetAddress = inetSocketAddress.getAddress();
|
||||
Iterator<IpFilterRule> iterator = ipFilterRuleList.iterator();
|
||||
IpFilterRule ipFilterRule = null;
|
||||
IpFilterRule ipFilterRule;
|
||||
while (iterator.hasNext()) {
|
||||
ipFilterRule = iterator.next();
|
||||
if (ipFilterRule.contains(inetAddress)) {
|
||||
|
@ -169,8 +169,6 @@ public class ChunkedWriteHandler
|
||||
cause = new ClosedChannelException();
|
||||
}
|
||||
currentEvent.getFuture().setFailure(cause);
|
||||
|
||||
currentEvent = null;
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +182,7 @@ public class ChunkedWriteHandler
|
||||
}
|
||||
|
||||
private void flush(ChannelHandlerContext ctx, boolean fireNow) throws Exception {
|
||||
boolean acquired = false;
|
||||
boolean acquired;
|
||||
final Channel channel = ctx.getChannel();
|
||||
boolean suspend = false;
|
||||
flushNeeded = true;
|
||||
@ -363,8 +361,6 @@ public class ChunkedWriteHandler
|
||||
}
|
||||
currentEvent.getFuture().setFailure(cause);
|
||||
fireExceptionCaught = true;
|
||||
|
||||
currentEvent = null;
|
||||
}
|
||||
|
||||
if (fireExceptionCaught) {
|
||||
|
@ -355,7 +355,7 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
long curtime = System.currentTimeMillis();
|
||||
long size = objectSizeEstimator.estimateSize(evt.getMessage());
|
||||
if (trafficCounter != null) {
|
||||
trafficCounter.bytesRecvFlowControl(ctx, size);
|
||||
trafficCounter.bytesRecvFlowControl(size);
|
||||
if (readLimit == 0) {
|
||||
// no action
|
||||
return;
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.traffic;
|
||||
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.util.Timeout;
|
||||
import org.jboss.netty.util.Timer;
|
||||
import org.jboss.netty.util.TimerTask;
|
||||
@ -151,7 +150,7 @@ public class TrafficCounter {
|
||||
if (trafficShapingHandler1 != null) {
|
||||
trafficShapingHandler1.doAccounting(counter);
|
||||
}
|
||||
timeout =
|
||||
|
||||
counter.timer.newTimeout(this, counter.checkInterval.get(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
@ -254,12 +253,10 @@ public class TrafficCounter {
|
||||
/**
|
||||
* Computes counters for Read.
|
||||
*
|
||||
* @param ctx
|
||||
* the associated channelHandlerContext
|
||||
* @param recv
|
||||
* the size in bytes to read
|
||||
*/
|
||||
void bytesRecvFlowControl(ChannelHandlerContext ctx, long recv) {
|
||||
void bytesRecvFlowControl(long recv) {
|
||||
currentReadBytes.addAndGet(recv);
|
||||
cumulativeReadBytes.addAndGet(recv);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public final class DetectionUtil {
|
||||
}
|
||||
|
||||
// Legacy properties
|
||||
boolean tryUnsafe = false;
|
||||
boolean tryUnsafe;
|
||||
if (SystemPropertyUtil.contains("io.netty.tryUnsafe")) {
|
||||
tryUnsafe = SystemPropertyUtil.getBoolean("io.netty.tryUnsafe", true);
|
||||
} else {
|
||||
|
@ -31,7 +31,7 @@ public final class StringUtil {
|
||||
public static final String NEWLINE;
|
||||
|
||||
static {
|
||||
String newLine = null;
|
||||
String newLine;
|
||||
|
||||
try {
|
||||
newLine = new Formatter().format("%n").toString();
|
||||
|
@ -349,7 +349,7 @@ final class Deflate {
|
||||
int n; // iterates over all tree elements
|
||||
int prevlen = -1; // last emitted length
|
||||
int curlen; // length of current code
|
||||
int nextlen = tree[0 * 2 + 1]; // length of next code
|
||||
int nextlen = tree[1]; // length of next code
|
||||
int count = 0; // repeat count of the current code
|
||||
int max_count = 7; // max repeat count
|
||||
int min_count = 4; // min repeat count
|
||||
@ -445,7 +445,7 @@ final class Deflate {
|
||||
int n; // iterates over all tree elements
|
||||
int prevlen = -1; // last emitted length
|
||||
int curlen; // length of current code
|
||||
int nextlen = tree[0 * 2 + 1]; // length of next code
|
||||
int nextlen = tree[1]; // length of next code
|
||||
int count = 0; // repeat count of the current code
|
||||
int max_count = 7; // max repeat count
|
||||
int min_count = 4; // min repeat count
|
||||
@ -799,6 +799,7 @@ final class Deflate {
|
||||
int stored_len, // length of input block
|
||||
boolean eof // true if this is the last block for a file
|
||||
) {
|
||||
//noinspection PointlessArithmeticExpression
|
||||
send_bits((STORED_BLOCK << 1) + (eof? 1 : 0), 3); // send block type
|
||||
copy_block(buf, stored_len, true); // with header
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ final class InfCodes {
|
||||
int j; // temporary storage
|
||||
int tindex; // temporary pointer
|
||||
int e; // extra bits or operation
|
||||
int b = 0; // bit buffer
|
||||
int k = 0; // bits in bit buffer
|
||||
int p = 0; // input data pointer
|
||||
int b; // bit buffer
|
||||
int k; // bits in bit buffer
|
||||
int p; // input data pointer
|
||||
int n; // bytes available there
|
||||
int q; // output window write pointer
|
||||
int m; // bytes to end of window or read pointer
|
||||
@ -587,7 +587,6 @@ final class InfCodes {
|
||||
q, e);
|
||||
q += e;
|
||||
r += e;
|
||||
e = 0;
|
||||
}
|
||||
r = 0; // copy rest from start of window
|
||||
}
|
||||
@ -603,7 +602,6 @@ final class InfCodes {
|
||||
System.arraycopy(s.window, r, s.window, q, c);
|
||||
q += c;
|
||||
r += c;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
} else if ((e & 64) == 0) {
|
||||
|
@ -212,7 +212,7 @@ final class Tree {
|
||||
continue;
|
||||
}
|
||||
if (tree[m * 2 + 1] != bits) {
|
||||
s.opt_len += ((long) bits - (long) tree[m * 2 + 1]) *
|
||||
s.opt_len += ((long) bits - tree[m * 2 + 1]) *
|
||||
tree[m * 2];
|
||||
tree[m * 2 + 1] = (short) bits;
|
||||
}
|
||||
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.jboss.netty.buffer;
|
||||
|
||||
import static org.jboss.netty.buffer.ChannelBuffers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import org.easymock.EasyMock;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -27,9 +28,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
import org.junit.Test;
|
||||
import static org.jboss.netty.buffer.ChannelBuffers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests channel buffers
|
||||
@ -174,10 +174,10 @@ public class ChannelBuffersTest {
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new byte[][] { new byte[0] }));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ByteBuffer[0]));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ByteBuffer[] { ByteBuffer.allocate(0) }));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ByteBuffer[] { ByteBuffer.allocate(0), ByteBuffer.allocate(0) }));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(ByteBuffer.allocate(0), ByteBuffer.allocate(0)));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ChannelBuffer[0]));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ChannelBuffer[] { buffer(0) }));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(new ChannelBuffer[] { buffer(0), buffer(0) }));
|
||||
assertSame(EMPTY_BUFFER, wrappedBuffer(buffer(0), buffer(0)));
|
||||
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new byte[0]));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(LITTLE_ENDIAN, new byte[0]));
|
||||
@ -191,10 +191,10 @@ public class ChannelBuffersTest {
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new byte[][] { new byte[0] }));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ByteBuffer[0]));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ByteBuffer[] { ByteBuffer.allocate(0) }));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ByteBuffer[] { ByteBuffer.allocate(0), ByteBuffer.allocate(0) }));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(ByteBuffer.allocate(0), ByteBuffer.allocate(0)));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ChannelBuffer[0]));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ChannelBuffer[] { buffer(0) }));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(new ChannelBuffer[] { buffer(0), buffer(0) }));
|
||||
assertSame(EMPTY_BUFFER, copiedBuffer(buffer(0), buffer(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -123,7 +123,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
assertEquals("processed: payload", customTextFrameHandler.getContent());
|
||||
}
|
||||
|
||||
private DecoderEmbedder<Object> decoderEmbedder(SimpleChannelHandler handler) {
|
||||
private static DecoderEmbedder<Object> decoderEmbedder(SimpleChannelHandler handler) {
|
||||
DecoderEmbedder<Object> decoder = decoderEmbedder();
|
||||
decoder.getPipeline().addFirst("someHandler", handler);
|
||||
return decoder;
|
||||
|
@ -26,6 +26,8 @@ import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public abstract class AbstractCompatibleMarshallingEncoderTest {
|
||||
|
||||
@Test
|
||||
@ -39,18 +41,18 @@ public abstract class AbstractCompatibleMarshallingEncoderTest {
|
||||
EncoderEmbedder<ChannelBuffer> encoder = new EncoderEmbedder<ChannelBuffer>(createEncoder());
|
||||
|
||||
encoder.offer(testObject);
|
||||
Assert.assertTrue(encoder.finish());
|
||||
assertTrue(encoder.finish());
|
||||
|
||||
ChannelBuffer buffer = encoder.poll();
|
||||
|
||||
Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
|
||||
unmarshaller.start(Marshalling.createByteInput(truncate(buffer).toByteBuffer()));
|
||||
String read = (String) unmarshaller.readObject();
|
||||
Assert.assertEquals(testObject, read);
|
||||
assertEquals(testObject, read);
|
||||
|
||||
Assert.assertEquals(-1, unmarshaller.read());
|
||||
assertEquals(-1, unmarshaller.read());
|
||||
|
||||
Assert.assertNull(encoder.poll());
|
||||
assertNull(encoder.poll());
|
||||
|
||||
unmarshaller.finish();
|
||||
unmarshaller.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user