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

FileInputStream.skip(long) does not stop at EOF

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      This is a duplication of 4454092 bug.

      When the skip(long) method is used from any position in the stream with a skip
      value that is larger than the available bytes in the stream, the skip method
      skips beyond EOF and returns the same value that was given to it.
      See code below.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run following program

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JVM: Sun Microsystems Inc. 1.5.0_04
      Skiped bytes: 1501
      ACTUAL -
      JVM: Sun Microsystems Inc. 1.5.0_04
      Skiped bytes: 100000000

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.io.InputStream;

      public
      class SkipTest
      {

      public static
      void main(String[] args)
      throws IOException
      {
      InputStream is=SkipTest.class.getResourceAsStream("SkipTest.class");
      long stream_size=is.skip(100000000);
      System.out.println("JVM: "+System.getProperty("java.vendor")+" "+System.getProperty("java.version"));
      System.out.println("Skiped bytes: "+stream_size);
      }

      }

      ---------- END SOURCE ----------
      ###@###.### 2005-07-08 13:07:58 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dxu Dan Xu (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: