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

document for java.util.zip.DeflaterOutputStream(OutputStream,Deflater,int) uncle

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5
    • Verified



      Name: sdC67446 Date: 02/24/98


      The specification for java.util.zip.DeflaterOutputStream(OutputStream os,
      Deflater def, int size) does not specify behavior for argument size when
      it is negative. The current behavior is to throw an
      NegativeArraySizeException. More acceptable behavior for negative argument
      here is to throw IllegalArgumentException unless otherwise specified.
      The similar bug is present in InflaterInputStream, GZIPInputStream,
      GZIPOutputStream constructors as well.

      Here is what doc says:
      --------------------------------------------------
      public InflaterInputStream(InputStream in,
                                 Inflater inf,
                                 int size)

      Creates a new input stream with the specified decompressor and buffer size.
         Parameters:
           in - the input stream
           inf - the decompressor ("inflater")
           len - the input buffer size

      -----------------Test.java------------------------
      import java.util.zip.*;
      import java.io.*;

      public class Test {
        
        public static void main(String[] args) {
          try {
            
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Deflater def = new Deflater();
            
            DeflaterOutputStream defOS = new DeflaterOutputStream(bos, def, -1);
            
          } catch (NegativeArraySizeException e) {
            System.out.println(e);
          }
        }
      }
      ---------Output from the test---------------------
      java.lang.NegativeArraySizeException
      --------------------------------------------------

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

            zlisunw Zhenghua Li (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: