Fix more inspection warnings + compilation errors
This commit is contained in:
parent
36c8eb02e8
commit
a05064d3eb
@ -72,7 +72,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,9 +15,6 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import static io.netty.buffer.Unpooled.EMPTY_BUFFER;
|
||||
import static io.netty.buffer.Unpooled.buffer;
|
||||
import static io.netty.buffer.Unpooled.wrappedBuffer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
@ -30,6 +27,8 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
|
||||
/**
|
||||
* Abstract Memory HttpData implementation
|
||||
*/
|
||||
@ -157,7 +156,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
return "";
|
||||
}
|
||||
if (encoding == null) {
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
encoding = HttpConstants.DEFAULT_CHARSET;
|
||||
}
|
||||
return byteBuf.toString(encoding);
|
||||
}
|
||||
|
@ -441,8 +441,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;
|
||||
}
|
||||
@ -492,7 +492,6 @@ public class HttpPostRequestDecoder {
|
||||
contRead = false;
|
||||
} else {
|
||||
// Error
|
||||
contRead = false;
|
||||
throw new ErrorDataDecoderException("Bad end of line");
|
||||
}
|
||||
} else {
|
||||
@ -553,7 +552,7 @@ public class HttpPostRequestDecoder {
|
||||
* errors
|
||||
*/
|
||||
private void parseBodyAttributes() throws ErrorDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -562,8 +561,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 {
|
||||
@ -833,7 +831,7 @@ public class HttpPostRequestDecoder {
|
||||
* @throws NotEnoughDataDecoderException
|
||||
*/
|
||||
void skipControlCharacters() throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e) {
|
||||
@ -937,7 +935,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);
|
||||
} else {
|
||||
@ -1218,7 +1216,7 @@ public class HttpPostRequestDecoder {
|
||||
* value
|
||||
*/
|
||||
private String readLine() throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1364,7 +1362,7 @@ public class HttpPostRequestDecoder {
|
||||
* value
|
||||
*/
|
||||
private String readDelimiter(String delimiter) throws NotEnoughDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1573,7 +1571,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) {
|
||||
@ -1585,7 +1583,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) {
|
||||
@ -1769,7 +1767,7 @@ public class HttpPostRequestDecoder {
|
||||
* @throws ErrorDataDecoderException
|
||||
*/
|
||||
private void loadFieldMultipart(String delimiter) throws NotEnoughDataDecoderException, ErrorDataDecoderException {
|
||||
SeekAheadOptimize sao = null;
|
||||
SeekAheadOptimize sao;
|
||||
try {
|
||||
sao = new SeekAheadOptimize(undecodedChunk);
|
||||
} catch (SeekAheadNoBackArrayException e1) {
|
||||
@ -1781,7 +1779,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;
|
||||
|
||||
@ -1871,8 +1869,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);
|
||||
@ -1976,7 +1973,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 {
|
||||
|
@ -467,7 +467,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
||||
// 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())) {
|
||||
// continue a mixed mode
|
||||
@ -918,7 +918,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
|
||||
isLastChunkSent = true;
|
||||
return new DefaultHttpChunk(EMPTY_BUFFER);
|
||||
}
|
||||
ByteBuf buffer = null;
|
||||
ByteBuf buffer;
|
||||
int size = HttpPostBodyUtil.chunkSize;
|
||||
// first test if previous buffer is not empty
|
||||
if (currentBuffer != null) {
|
||||
|
@ -168,7 +168,7 @@ public class WebSocket08FrameEncoder extends MessageToByteEncoder<WebSocketFrame
|
||||
int counter = 0;
|
||||
for (int i = data.readerIndex(); i < data.writerIndex(); i ++) {
|
||||
byte byteData = data.getByte(i);
|
||||
out.writeByte(byteData ^ mask[+counter++ % 4]);
|
||||
out.writeByte(byteData ^ mask[counter++ % 4]);
|
||||
}
|
||||
} else {
|
||||
out.writeBytes(data, data.readerIndex(), data.readableBytes());
|
||||
|
@ -182,7 +182,7 @@ public class SpdyFrameEncoder extends MessageToByteEncoder<Object> {
|
||||
out.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;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class SpdyHttpResponseStreamIdHandler extends
|
||||
@Override
|
||||
public HttpMessage encode(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
|
||||
Integer id = ids.poll();
|
||||
if (id != null && id != NO_ID && !msg.containsHeader(SpdyHttpHeaders.Names.STREAM_ID)) {
|
||||
if (id != null && id.intValue() != NO_ID && !msg.containsHeader(SpdyHttpHeaders.Names.STREAM_ID)) {
|
||||
SpdyHttpHeaders.setStreamId(msg, id);
|
||||
}
|
||||
return msg;
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
@ -31,6 +29,8 @@ import io.netty.handler.codec.http.HttpRequestDecoder;
|
||||
import io.netty.handler.codec.http.HttpResponseEncoder;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
/**
|
||||
* {@link ChannelInboundByteHandler} which is responsible to setup the {@link ChannelPipeline} either for
|
||||
* HTTP or SPDY. This offers an easy way for users to support both at the same time while not care to
|
||||
@ -89,7 +89,6 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
|
||||
throw new IllegalStateException("SslHandler is needed for SPDY");
|
||||
}
|
||||
|
||||
ChannelPipeline pipeline = ctx.pipeline();
|
||||
SelectedProtocol protocol = getProtocol(handler.getEngine());
|
||||
switch (protocol) {
|
||||
case None:
|
||||
|
@ -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 {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(createEncoder());
|
||||
|
||||
ch.writeOutbound(testObject);
|
||||
Assert.assertTrue(ch.finish());
|
||||
assertTrue(ch.finish());
|
||||
|
||||
ByteBuf buffer = ch.readOutbound();
|
||||
|
||||
Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
|
||||
unmarshaller.start(Marshalling.createByteInput(truncate(buffer).nioBuffer()));
|
||||
String read = (String) unmarshaller.readObject();
|
||||
Assert.assertEquals(testObject, read);
|
||||
assertEquals(testObject, read);
|
||||
|
||||
Assert.assertEquals(-1, unmarshaller.read());
|
||||
assertEquals(-1, unmarshaller.read());
|
||||
|
||||
Assert.assertNull(ch.readOutbound());
|
||||
assertNull(ch.readOutbound());
|
||||
|
||||
unmarshaller.finish();
|
||||
unmarshaller.close();
|
||||
|
@ -114,7 +114,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 {
|
||||
|
@ -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
|
||||
@ -797,6 +797,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) {
|
||||
|
@ -213,7 +213,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;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
responseContent.append('o');
|
||||
// example of reading chunk by chunk (minimize memory usage due to
|
||||
// Factory)
|
||||
readHttpDataChunkByChunk(ctx.channel());
|
||||
readHttpDataChunkByChunk();
|
||||
// example of reading only if at the end
|
||||
if (chunk.isLast()) {
|
||||
readHttpDataAllReceive(ctx.channel());
|
||||
@ -206,7 +206,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
* 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) {
|
||||
@ -226,7 +226,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
/**
|
||||
* 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();
|
||||
|
@ -1433,20 +1433,22 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
|
||||
private static boolean inExceptionCaught(Throwable cause) {
|
||||
for (;;) {
|
||||
if (cause == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StackTraceElement[] trace = cause.getStackTrace();
|
||||
if (trace != null) {
|
||||
for (StackTraceElement t: trace) {
|
||||
for (StackTraceElement t : trace) {
|
||||
if ("exceptionCaught".equals(t.getMethodName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inExceptionCaught(cause.getCause());
|
||||
cause = cause.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDuplicateName(String name) {
|
||||
|
@ -40,32 +40,33 @@ final class CombinedIterator<E> implements Iterator<E> {
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
for (;;) {
|
||||
try {
|
||||
return currentIterator.next();
|
||||
} catch (NoSuchElementException e) {
|
||||
if (currentIterator == i1) {
|
||||
currentIterator = i2;
|
||||
return next();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
@ -116,14 +116,8 @@ public final class SctpMessage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder().
|
||||
append("SctpFrame{").
|
||||
append("streamIdentifier=").
|
||||
append(streamIdentifier).
|
||||
append(", protocolIdentifier=").
|
||||
append(protocolIdentifier).
|
||||
append(", payloadBuffer=").
|
||||
append(ByteBufUtil.hexDump(getPayloadBuffer())).
|
||||
append('}').toString();
|
||||
return "SctpFrame{" +
|
||||
"streamIdentifier=" + streamIdentifier + ", protocolIdentifier=" + protocolIdentifier +
|
||||
", payloadBuffer=" + ByteBufUtil.hexDump(getPayloadBuffer()) + '}';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user