Avoid casting numbers to narrower types (#10645)

Motivation:

Avoid implicit conversions to narrower types in
AbstractMemoryHttpData and Bzip2HuffmanStageEncoder classes
reported by LGTM.

Modifications:

Updated the classes to avoid implicit casting to narrower types.
It doesn't look like that an integer overflow is possible there,
therefore no checks for overflows were added.

Result:

No warnings about implicit conversions to narrower types.
This commit is contained in:
Artem Smotrakov 2020-10-12 09:33:47 +02:00 committed by Norman Maurer
parent 327071c7b3
commit 97c7c00dd5
2 changed files with 2 additions and 2 deletions

View File

@ -235,7 +235,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
return true;
}
int length = byteBuf.readableBytes();
int written = 0;
long written = 0;
RandomAccessFile accessFile = new RandomAccessFile(dest, "rw");
try {
FileChannel fileChannel = accessFile.getChannel();

View File

@ -219,7 +219,7 @@ final class Bzip2HuffmanStageEncoder {
final int groupEnd = Math.min(groupStart + HUFFMAN_GROUP_RUN_LENGTH, mtfLength) - 1;
// Calculate the cost of this group when encoded by each table
short[] cost = new short[totalTables];
int[] cost = new int[totalTables];
for (int i = groupStart; i <= groupEnd; i++) {
final int value = mtfBlock[i];
for (int j = 0; j < totalTables; j++) {