HADOOP-14914. Change to a safely casting long to int. Contributed by Ajay Kumar.

This commit is contained in:
Chen Liang 2017-12-13 14:56:14 -08:00
parent d447152d49
commit 46e18c8da7
3 changed files with 3 additions and 3 deletions

View File

@ -111,7 +111,7 @@ public class StripedBlockChecksumReconstructor extends StripedReconstructor {
// case-1) length of data bytes which is fraction of bytesPerCRC
// case-2) length of data bytes which is less than bytesPerCRC
if (requestedLen <= toReconstructLen) {
int remainingLen = (int) requestedLen;
int remainingLen = Math.toIntExact(requestedLen);
outputData = Arrays.copyOf(targetBuffer.array(), remainingLen);
int partialLength = remainingLen % getChecksum().getBytesPerChecksum();

View File

@ -605,7 +605,7 @@ public class DirectoryCollection {
if (totalSpace != 0) {
long tmp = ((totalSpace - usableSpace) * 100) / totalSpace;
if (Integer.MIN_VALUE < tmp && Integer.MAX_VALUE > tmp) {
goodDirsDiskUtilizationPercentage = (int) tmp;
goodDirsDiskUtilizationPercentage = Math.toIntExact(tmp);
}
} else {
// got no good dirs

View File

@ -228,7 +228,7 @@ public class NodeManagerHardwareUtils {
// on a single core machine - tmp can be between 0 and 1
cores = 1;
} else {
cores = (int) tmp;
cores = Math.round(tmp);
}
} else {
message = "Illegal value for "