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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 15, 16
    • core-libs
    • b15
    • generic
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: