Skip to content

Commit

Permalink
various errorprone fixes.
Browse files Browse the repository at this point in the history
Motivation:

Continuing to make netty happy when compiling through errorprone.

Modification:

Mostly comments, some minor switch statement changes.

Result:

No more compiler errors!
  • Loading branch information
Derek Perez authored and normanmaurer committed Aug 23, 2017
1 parent cbce95e commit b18a201
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t

streamCRC = 0;
currentState = State.INIT_BLOCK;
// fall through
case INIT_BLOCK:
if (!reader.hasReadableBytes(10)) {
return;
Expand All @@ -125,6 +126,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
}
blockCRC = reader.readInt();
currentState = State.INIT_BLOCK_PARAMS;
// fall through
case INIT_BLOCK_PARAMS:
if (!reader.hasReadableBits(25)) {
return;
Expand All @@ -135,12 +137,14 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
blockDecompressor = new Bzip2BlockDecompressor(this.blockSize, blockCRC,
blockRandomised, bwtStartPointer, reader);
currentState = State.RECEIVE_HUFFMAN_USED_MAP;
// fall through
case RECEIVE_HUFFMAN_USED_MAP:
if (!reader.hasReadableBits(16)) {
return;
}
blockDecompressor.huffmanInUse16 = reader.readBits(16);
currentState = State.RECEIVE_HUFFMAN_USED_BITMAPS;
// fall through
case RECEIVE_HUFFMAN_USED_BITMAPS:
Bzip2BlockDecompressor blockDecompressor = this.blockDecompressor;
final int inUse16 = blockDecompressor.huffmanInUse16;
Expand Down Expand Up @@ -175,6 +179,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
}
huffmanStageDecoder = new Bzip2HuffmanStageDecoder(reader, totalTables, alphaSize);
currentState = State.RECEIVE_SELECTORS_NUMBER;
// fall through
case RECEIVE_SELECTORS_NUMBER:
if (!reader.hasReadableBits(15)) {
return;
Expand All @@ -186,6 +191,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
huffmanStageDecoder.selectors = new byte[totalSelectors];

currentState = State.RECEIVE_SELECTORS;
// fall through
case RECEIVE_SELECTORS:
Bzip2HuffmanStageDecoder huffmanStageDecoder = this.huffmanStageDecoder;
byte[] selectors = huffmanStageDecoder.selectors;
Expand All @@ -209,6 +215,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
}

currentState = State.RECEIVE_HUFFMAN_LENGTH;
// fall through
case RECEIVE_HUFFMAN_LENGTH:
huffmanStageDecoder = this.huffmanStageDecoder;
totalTables = huffmanStageDecoder.totalTables;
Expand Down Expand Up @@ -268,6 +275,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
// Finally create the Huffman tables
huffmanStageDecoder.createHuffmanDecodingTables();
currentState = State.DECODE_HUFFMAN_DATA;
// fall through
case DECODE_HUFFMAN_DATA:
blockDecompressor = this.blockDecompressor;
final int oldReaderIndex = in.readerIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws
out.writeMedium(MAGIC_NUMBER);
out.writeByte('0' + streamBlockSize / BASE_BLOCK_SIZE);
currentState = State.INIT_BLOCK;
// fall through
case INIT_BLOCK:
blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize);
currentState = State.WRITE_DATA;
// fall through
case WRITE_DATA:
if (!in.isReadable()) {
return;
Expand All @@ -132,6 +134,7 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws
}
}
currentState = State.CLOSE_BLOCK;
// fall through
case CLOSE_BLOCK:
closeBlock(out);
currentState = State.INIT_BLOCK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ static void allocateHuffmanCodeLengths(final int[] array, final int maximumLengt
switch (array.length) {
case 2:
array[1] = 1;
// fall through
case 1:
array[0] = 1;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static int calculateOutputBufferLength(int inputLength) {
*
* If the input is not compressible, the return value might be larger than length (input buffer size).
*/
@SuppressWarnings("IdentityBinaryExpression")
static int compress(final byte[] input, final int inOffset, final int inLength,
final byte[] output, final int outOffset, final int proposedLevel) {
final int level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
hasChecksum = (options & 0x10) == BLOCK_WITH_CHECKSUM;

currentState = State.INIT_BLOCK_PARAMS;
// fall through
case INIT_BLOCK_PARAMS:
if (in.readableBytes() < 2 + (isCompressed ? 2 : 0) + (hasChecksum ? 4 : 0)) {
break;
Expand All @@ -135,6 +136,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
originalLength = isCompressed ? in.readUnsignedShort() : chunkLength;

currentState = State.DECOMPRESS_DATA;
// fall through
case DECOMPRESS_DATA:
final int chunkLength = this.chunkLength;
if (in.readableBytes() < chunkLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ private boolean readGZIPHeader(ByteBuf in) {
crc.update(in.readUnsignedByte()); // operating system

gzipState = GzipState.FLG_READ;
// fall through
case FLG_READ:
if ((flags & FEXTRA) != 0) {
if (in.readableBytes() < 2) {
Expand All @@ -282,6 +283,7 @@ private boolean readGZIPHeader(ByteBuf in) {
xlen |= xlen1 << 8 | xlen2;
}
gzipState = GzipState.XLEN_READ;
// fall through
case XLEN_READ:
if (xlen != -1) {
if (in.readableBytes() < xlen) {
Expand All @@ -291,6 +293,7 @@ private boolean readGZIPHeader(ByteBuf in) {
in.skipBytes(xlen);
}
gzipState = GzipState.SKIP_FNAME;
// fall through
case SKIP_FNAME:
if ((flags & FNAME) != 0) {
if (!in.isReadable()) {
Expand All @@ -305,6 +308,7 @@ private boolean readGZIPHeader(ByteBuf in) {
} while (in.isReadable());
}
gzipState = GzipState.SKIP_COMMENT;
// fall through
case SKIP_COMMENT:
if ((flags & FCOMMENT) != 0) {
if (!in.isReadable()) {
Expand All @@ -319,6 +323,7 @@ private boolean readGZIPHeader(ByteBuf in) {
} while (in.isReadable());
}
gzipState = GzipState.PROCESS_FHCRC;
// fall through
case PROCESS_FHCRC:
if ((flags & FHCRC) != 0) {
if (in.readableBytes() < 4) {
Expand All @@ -328,6 +333,7 @@ private boolean readGZIPHeader(ByteBuf in) {
}
crc.reset();
gzipState = GzipState.HEADER_END;
// fall through
case HEADER_END:
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected final ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg,
case ZLIB:
sizeEstimate += 2; // first two magic bytes
break;
default:
// no op
}
}
return ctx.alloc().heapBuffer(sizeEstimate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
this.currentChecksum = currentChecksum;

currentState = State.DECOMPRESS_DATA;
// fall through
case DECOMPRESS_DATA:
blockType = this.blockType;
compressedLength = this.compressedLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
if (type != BLOCK_TYPE_COMPRESSED) {
break;
}
// fall through
case INIT_ORIGINAL_LENGTH:
if (in.readableBytes() < 2) {
break;
}
originalLength = in.readUnsignedShort();

currentState = State.DECOMPRESS_DATA;
// fall through
case DECOMPRESS_DATA:
final int chunkLength = this.chunkLength;
if (in.readableBytes() < chunkLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public void decode(ByteBuf in, ByteBuf out) {
switch (state) {
case READY:
state = State.READING_PREAMBLE;
// fall through
case READING_PREAMBLE:
int uncompressedLength = readPreamble(in);
if (uncompressedLength == PREAMBLE_NOT_FULL) {
Expand All @@ -285,6 +286,7 @@ public void decode(ByteBuf in, ByteBuf out) {
}
out.ensureWritable(uncompressedLength);
state = State.READING_TAG;
// fall through
case READING_TAG:
if (!in.isReadable()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public static List<CharSequence> unescapeCsvFields(CharSequence value) {
break;
}
// double-quote appears without being enclosed with double-quotes
// fall through
case LINE_FEED:
// fall through
case CARRIAGE_RETURN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ protected void run() {
if (wakenUp.get()) {
selector.wakeup();
}
// fall through
default:
// fallthrough
}

cancelledKeys = 0;
Expand Down

0 comments on commit b18a201

Please sign in to comment.