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

java.io.LineNumberInpupStream.skip doesn't handle CR/LF properly

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta3
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: saC57035 Date: 11/11/97


      Method java.io.LineNumberInpupStream.skip(long n) does not recognize
      CR/LF pair as _one_ EOL character.

      According to the specs, method read of LineNumberInputStream
      converts CR/LF pairs into LF character. Method skip should
      call read to skip required number of bytes, thus counting that pair as
      one character.


      The test below reveals incorrect behaviour:
      ------- SkipTest.java -------------
      import java.io.*;

      public class SkipTest {

        public static void main( String argv[] ) {
          byte[] data = {12,13,10,23,11};
          LineNumberInputStream in = new LineNumberInputStream(new ByteArrayInputStream(data));
          try {
            long skipped = in.skip(3); // skip 3 bytes
            System.out.println("Skipped: "+skipped);
            System.out.println("next byte: "+in.read());
          }
          catch(Throwable e) // Test no exceptions are thrown
          { System.out.println( "Unexpected "+e+" thrown" );
          }
      }

      }
      ---------- output ------------------

      134% java SkipTest
      Skipped: 3
      next byte: 23
      ------------------------------------

      Next byte should be 11 in this case.

      Please note that the regression took place in most recent (as of today)
      build only - JDK 1.2S. Previous builds as well as JDK 1.1.X builds don't
      have this problem.

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            dviswanasunw Deepa Viswanathan (Inactive)
            Reporter:
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: