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

InflaterInputStream doesn't support mark and reset

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.1
    • core-libs
    • x86
    • windows_2000



      Name: rmT116609 Date: 02/06/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Inflator input stream returns true from the markSupported
      method, yet doesn't support resetting to a mark. The
      submitted example program works if the deflator and inflator
      are removed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See example program.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      expected:
      one
      two
      We can mark this stream.
      one
      one

      actual:
      one
      two
      We can mark this stream.
      one
      two

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.util.zip.*;

      public class Test {

      public static void main(String[] argv) throws Exception {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          DataOutputStream out =
              new DataOutputStream(
                  new DeflaterOutputStream( bytes ) );
          out.writeUTF("one");
          out.writeUTF("two");
          out.close();

          DataInputStream in =
              new DataInputStream(
                  new InflaterInputStream(
                      new ByteArrayInputStream( bytes.toByteArray() ) ) );

          System.out.println(in.readUTF()); // prints "one"
          System.out.println(in.readUTF()); // print "two"

          // So far, so good. Now the bug.
          in = // the same DataInputStream as before
              new DataInputStream(
                  new InflaterInputStream(
                      new ByteArrayInputStream( bytes.toByteArray() ) ) );

          if (in.markSupported())
              System.out.println("We can mark this stream.");
          in.mark(2000);
          System.out.println(in.readUTF()); // prints "one"
          in.reset();
          System.out.println(in.readUTF()); // prints "two", but should print "one"
      }

      }
      ---------- END SOURCE ----------
      (Review ID: 164169)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: