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

java.sql.DriverManager.setLogStream(null) works wrong (regression)

    XMLWordPrintable

    Details

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

      Description



      Name: mgC56079 Date: 02/10/98



      The java.sql.DriverManager.setLogStream(null) doesn't work as specified.
      According to the javadoc comment it should turn the logstream off.
      It fails to do so correctly. This may result in a NullPointerException
      in DriverManager.println(String) method.

      Here is a simple test demonstrating the bug:
      ======= DriverManager2.java =======
      import java.sql.DriverManager;

      public class DriverManager2 {

      public static void main(String args[]) {
        DriverManager.setLogStream(null); // turn logstream off
        for (int i=0; i<10000; i++) // this is a workaround for bug 4110926
                                    // (make sure the internal buffer
                                    // in PrintWriter is flushed).
          DriverManager.println("message");
      }

      }
      ======= Here is the output under jdk1.1.x (correct) =======
      % java DriverManager2
      ======= Here is the output under jdk1.2beta3F (wrong) =======
      % java DriverManager2
      java.lang.NullPointerException
      at java.io.OutputStreamWriter.write(OutputStreamWriter.java:144)
      at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:123)
      at java.io.BufferedWriter.write(BufferedWriter.java:203)
      at java.io.Writer.write(Writer.java:117)
      at java.io.PrintWriter.newLine(PrintWriter.java:239)
      at java.io.PrintWriter.println(PrintWriter.java:373)
      at java.sql.DriverManager.println(DriverManager.java:376)
      at DriverManager2.main(DriverManager2.java:8)
      =======

      The bug is one of the causes for JCK test failure:
      api/java_sql/DriverManager/manual.html#DriverManager

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

        Attachments

          Activity

            People

            Assignee:
            swhitesunw Seth White (Inactive)
            Reporter:
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: