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

using System.setOut() will cause infintite loop

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 1.1.5
    • Fix Version/s: 1.1.5
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      generic, x86
    • OS:
      generic, windows_nt
    • Verification:
      Verified

      Description



      Name: chT40241 Date: 10/22/97


      The problem comes in our use of the following lines of code:
      java.io.PrintStream out = System.out;
      java.io.PrintStream err = System.err;
      try {
      System.setOut(null);
      System.setErr(null);
      } catch (Throwable t) { }
              try {
      System.out.println("Print something");
              } catch(Exception e) {e.printStackTrace();}
      try {
      System.setOut(out);
      System.setErr(err);
      } catch (Throwable t) { }
              System.out.println("Print something");

      There are two problems. First, setting System.out to null will cause a NullPointerException in System$DelegatingPrintStream because there is no protection on setting the delegate to null.
      Second, caching the System.out for later restoration will cause the DelgatingPrintStream to actually delegate to itself. This will cause the next call to System.out.println() to go into an infinitely recursive loop until all stack space is exhausted.

      This problem basically kills our use of 1.1.5
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              apalanissunw Anand Palaniswamy (Inactive)
              Reporter:
              chickeysunw Chuck Hickey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: