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