Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.1.0
-
None
-
None
Description
There are bunches of casting long to int like this:
long l = 123 int i = (int) l;
This is not a safe cast. if l is greater than Integer.MAX_VALUE, i would be negative, which is an unexpected behavior. We probably at least want to throw an exception in that case. I suggest to use Math.toIntExact(longValue) to replace them, which throws an exception if the value overflows an int.