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

LOGGING APIs: readConfiguration(InputStream) throws undocumented IOException

XMLWordPrintable

    • beta
    • generic
    • generic
    • Verified



      Name: elR10090 Date: 10/20/2000



      Logging APIs specification (draft 0.49) doesn't state
      readConfiguration(InputStream) to throw IOException.

      The following test reveals that the method can throw it.
      I think this is right behavior and there is just misprint in specification.

      Log and test source follow:

      readcfgi004 log:

      # Unexpected exception while readConfiguration():
      # java.io.IOException: It happens sometimes
      # TEST FAILED.

      readcfgi004.java source:

      // File: @(#)readcfgi004.java 1.1 00/10/20
      // Copyright 10/20/00 Sun Microsystems, Inc. All Rights Reserved

      package logging.LogManager.readConfiguration_i;

      import java.util.logging.*;
      import java.io.*;

      public class readcfgi004 {

          final static int PASSED = 0;
          final static int FAILED = 2;
          final static int JCK_STATUS_BASE = 95;
          final static String failMessage = "# TEST FAILED.";

          private static boolean testFailed = false;

          public static int run(String args[], PrintStream out) {

              LogManager manager = LogManager.getLogManager();
              InputStream ins = new MyInputStream();
              try {
                  manager.readConfiguration(ins);
              } catch (Exception ex) {
                  out.println("# Unexpected exception while readConfiguration():");
                  out.println("# " + ex);
                  testFailed = true;
              };

              if (testFailed) {
                  out.println(failMessage);
                  return FAILED;
              } else {
                  return PASSED;
              }
          }

          static class MyInputStream extends InputStream {
              public int read() throws IOException {
                  throw new IOException("It happens sometimes");
              }
          }

          public static void main(String args[]) {
              // produce JCK-like exit status.
              System.exit(run(args, System.out) + JCK_STATUS_BASE);
          }
      }
       
      ======================================================================

            ghamiltosunw Graham Hamilton (Inactive)
            latkinsunw Latkin Latkin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: