Skip to content
Permalink
Browse files
8263742: (bf) MappedByteBuffer.force() should use the capacity as its…
… upper bound

Reviewed-by: adinn, alanb
  • Loading branch information
Brian Burkhalter committed Mar 18, 2021
1 parent c82a673 commit fa0f1614ffaeecca0b42d7b1ae044abdc1ae72ab
Showing 1 changed file with 8 additions and 8 deletions.
@@ -232,9 +232,9 @@ public final MappedByteBuffer force() {
if (fd == null) {
return this;
}
int limit = limit();
if (isSync || ((address != 0) && (limit != 0))) {
return force(0, limit);
int capacity = capacity();
if (isSync || ((address != 0) && (capacity != 0))) {
return force(0, capacity);
}
return this;
}
@@ -267,11 +267,11 @@ public final MappedByteBuffer force() {
* @param index
* The index of the first byte in the buffer region that is
* to be written back to storage; must be non-negative
* and less than limit()
* and less than {@code capacity()}
*
* @param length
* The length of the region in bytes; must be non-negative
* and no larger than limit() - index
* and no larger than {@code capacity() - index}
*
* @throws IndexOutOfBoundsException
* if the preconditions on the index and length do not
@@ -289,10 +289,10 @@ public final MappedByteBuffer force(int index, int length) {
if (fd == null) {
return this;
}
int limit = limit();
if ((address != 0) && (limit != 0)) {
int capacity = capacity();
if ((address != 0) && (capacity != 0)) {
// check inputs
Objects.checkFromIndexSize(index, length, limit);
Objects.checkFromIndexSize(index, length, capacity);
SCOPED_MEMORY_ACCESS.force(scope(), fd, address, isSync, index, length);
}
return this;

0 comments on commit fa0f161

Please sign in to comment.