HADOOP-14914. Change to a safely casting long to int. Contributed by Ajay Kumar.
This commit is contained in:
parent
d447152d49
commit
46e18c8da7
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Reference in New Issue