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

InflaterInputStream.read/skip methods does not throw IOE as expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.2
    • 1.1.7, 1.1.8
    • core-libs
    • None
    • 1.2.2
    • sparc
    • solaris_2.5
    • Verified



      Name: vsR10029 Date: 01/22/2001


      This bug is filed only for tracking purposes to exclude tests from
      TCKs for jdk1.1*-based products, the fix has already been integrated
      in jdk1.2, so feel free to close it as such.

      No IOException is thrown in InflaterInputStream.read/skip calls for
      already closed input stream.
      To reproduce run the code example:
      ---------------- TestIIS2.java ----------------------
      import java.io.ByteArrayInputStream;
      import java.io.IOException;
      import java.util.zip.InflaterInputStream;

      public class TestIIS2 {

          private final byte compressedOrig[] = {
              120, -100, -85, -107, -79, 74, 85, 97, 117,
              48, -9, 117, -47, 114, 15, -87, -27, -9, -54,
              -48, 49, -108, 17, 19, 20, 118, -87, -84, 78,
              -15, -10, -87, -112, 51, 115, 16, 85, 81, 54,
              11, 114, 44, 11, 98, 116, 17, 102, -10, 72,
              -10, 80, -79, 101, 14, 47, -50, 16, 117, -9,
              -83, 16, 13, -55, 83, 83, 103, -30, -117, -42,
              -82, -105, -119, 46, -16, 20, -111, -85, -16,
              -48, 54, 79, -53, -76, 116, -80, -78, 77, -88,
              -85, 50, 113, -54, 15, -74, -28, -44, 101,
              -43, 47, 85, 54, -74, 1, 0, -34, -35, 25, 7
          };

          public static void main(String argv[]) {
              TestIIS2 test = new TestIIS2();
              test.ioe();
          }

          public void ioe() {
              int i = 0;
              InflaterInputStream iis = null;
              try {
                  ByteArrayInputStream bis = new ByteArrayInputStream(compressedOrig);
                  iis = new InflaterInputStream(bis);
                  iis.close();
              } catch (Exception e) {
           System.out.println("Setup failed: " + e);
                  return;
              }
              try {
                  iis.read();
              } catch (IOException e) {
                  System.out.println("read() : OKAY");
                  i++;
              }
              try {
                  iis.read(new byte[5], 0, 3);
              } catch (IOException e) {
                  System.out.println("read(byte[] b, int off, int len) : OKAY");
                  i++;
              }
              try {
                  iis.skip(1);
              } catch (IOException e) {
                  System.out.println("skip(long n) : OKAY");
                  i++;
              }
              if (i != 3) {
                  System.out.println("IOException expected.");
              }
          }
      }
      ----------------------------------------------------

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

            kkladkosunw Konstantin Kladko (Inactive)
            visaenko Vasily Isaenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: