Ignore:
Timestamp:
2023-12-27T16:17:21+01:00 (18 months ago)
Author:
taylor.smock
Message:

See #23367: Give some indication when an integer overflow occurs

In this case, we are throwing an ArithmeticException when an overflow occurs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileRange.java

    r33285 r36198  
    4848     * Returns size
    4949     * @return size
     50     * @throws ArithmeticException – if the result overflows an int (see {@link Math#multiplyExact(int, int)})
    5051     */
    51     public int size() {
     52    public int size() throws ArithmeticException {
    5253        int xSpan = maxX - minX + 1;
    5354        int ySpan = maxY - minY + 1;
    54         return xSpan * ySpan;
     55        return Math.multiplyExact(xSpan, ySpan);
    5556    }
    5657}
Note: See TracChangeset for help on using the changeset viewer.