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

(fc) FileChannel javadoc not clear for cases where position == size

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 21
    • 7u40
    • core-libs
    • b12

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_40"
      Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
      Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux ida 3.10.11-100.fc18.x86_64 #1 SMP Mon Sep 9 13:06:31 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      This is a general, OS -type and -version independent issue.

      A DESCRIPTION OF THE PROBLEM :
      I've already described the problem here in detail with no satisfactory answers so far:

      http://stackoverflow.com/questions/20309154/is-this-an-off-by-one-bug-in-java-7



      REGRESSION. Last worked in version 7u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just **closely** read the documentation for FileChannel and the relevant code. Neither fully makes sense based on the standard notions of 'position' and 'size'.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I'm expecting that it should not be possible to read from a FileChannel at position == size(). The last position that can be read in a FileChannel should be size()-1 and not size().
      ACTUAL -
      Careless use of 'greater than' when 'greater than or equal to' should have been used in both the documentation and the code.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See the jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java file of Open JDK.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I do not know of any workaround. I need to ASAP what the semantics are so that I can build my own custom file system using the FileSystemProvider SPI. It would be immensely helpful if you could clarify/fix this issue ASAP.

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: