Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.8.0
-
None
-
None
-
Reviewed
Description
MAPREDUCE-6635 made this change:
- maxBytesToRead = Math.min(maxBytesToRead, - (int)(splitLength - totalBytesRead)); + long leftBytesForSplit = splitLength - totalBytesRead; + // check if leftBytesForSplit exceed Integer.MAX_VALUE + if (leftBytesForSplit <= Integer.MAX_VALUE) { + maxBytesToRead = Math.min(maxBytesToRead, (int)leftBytesForSplit); + }
The result is one more comparison than necessary and code that's a little convoluted. The code can be simplified as:
long leftBytesForSplit = splitLength - totalBytesRead; if (leftBytesForSplit < maxBytesToRead) { maxBytesToRead = (int)leftBytesForSplit; }
The comparison will auto promote maxBytesToRead, making it safe.