8288515: (ch) Unnecessary use of Math.addExact() in java.nio.channels.FileLock.overlaps()
Reviewed-by: alanb
This commit is contained in:
parent
72f286a9ba
commit
ef17ee4dea
@ -277,13 +277,10 @@ public abstract class FileLock implements AutoCloseable {
|
||||
if (size < 0)
|
||||
return false;
|
||||
|
||||
// Test whether this is below that
|
||||
try {
|
||||
if (Math.addExact(this.position, this.size) <= position)
|
||||
return false;
|
||||
} catch (ArithmeticException ignored) {
|
||||
// the sum of this.position and this.size overflows the range of
|
||||
// long hence their mathematical sum is greater than position
|
||||
// Test whether this is below that. The sum cannot overflow as the
|
||||
// size and position are immutable and were checked at construction.
|
||||
if (this.position + this.size <= position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if size == 0 then the specified lock range is unbounded and
|
||||
|
Loading…
x
Reference in New Issue
Block a user