Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8263742

(bf) MappedByteBuffer.force() should use the capacity as its upper bound

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15, 16
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b15
    • CPU:
      generic
    • OS:
      generic

      Description

      The fix for JDK-8221696 added MappedByteBuffer(int index, int length) to allow specifying a range to write back to storage. The no-arg MappedByteBuffer at this time and before wrote back the entire buffer content, i.e., the half-open range [0,capacity()). The new force(int,int) checked its parameters using Objects.checkFromIndexSize(index, length, limit()), i.e., with the limit instead of the capacity as upper bound. In JDK-8243491 the no-arg force() was changed as

      @@ -293,8 +227,7 @@ public abstract class MappedByteBuffer
                   return force(0, limit());
               }
               if ((address != 0) && (capacity() != 0)) {
      - long offset = mappingOffset();
      - force0(fd, mappingAddress(offset), mappingLength(offset));
      + return force(0, capacity());
               }
               return this;
           }

      to call the new force(int,int). This inadvertently changed the upper bound of the no-arg force() from capacity() to limit() thereby provoking JDK-8246729. The upper bound of force() should be the capacity.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              bpb Brian Burkhalter
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: