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

java.io.FilterOutputStream constructor does not check null parameter

XMLWordPrintable

    • sparc
    • solaris_2.5

      The java.io.FilterOutputStream constructor FilterOutputStream(OutputStream out)
      accepts and does not check null parameter. It creates a FilterOutputStream
      object with an invalid state: every call to this object results in throwing
      undocumented NullPointerException.

      Here is the example demonstrating this bug

      _______________________Test.java ______________________________________
      import java.io.*;

      public class Test {

      public static void main( String argv[] ) {

       MyFilterOutputStream os = new MyFilterOutputStream(null);
       try {
         os.write(25);
         System.out.println("No exceptions - rather strange but alright");
       } catch (IOException e) {
         System.out.println("IOException is thrown - possible result");
       } catch (Throwable e) {
         System.out.println(e+" is thrown - this is not allowed");
       }
      }

      }

      class MyFilterOutputStream extends FilterOutputStream {
      public MyFilterOutputStream (OutputStream out) { super(out); }
      }
      _____________________Output_________________________________________

      java.lang.NullPointerException is thrown - this is not allowed
      ____________________________________________________________________
        

            zlisunw Zhenghua Li (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: