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

Logging APIs: SocketHandler constructors spec need clarification

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: elR10090 Date: 12/15/2000



      The Logging APIs specification (draft 0.55) states:

      | SocketHandler()
      |
      | public SocketHandler(java.lang.String host, int port)
      |
      | Create a SocketHandler, using only LogManager properties
      | (or their defaults).
      |
      | SocketHandler(String, int)
      |
      | public SocketHandler(java.lang.String host, int port)
      |
      | Construct a SocketHandler using a specified host and port.
      | The SocketHandler is configured based on LogManager properties
      | (or their default values) except that the given target host
      | and port arguments are used.
      |
      | Parameters:
      | hostName - target host.
      | port - target port.

      I suppose next to the last string contains a misprint and should be:

              host - target host name.

      Moreover, the spec doesn't state anything about the case when
      arguments are not properly defined. What happens if target host name
      would be null or if properties are not defined when used SocketHandler()
      constructor?

      The following is spec for the method java.net.InetAddress.getByName
      (JDK 1.3 API docs):

      | getByName
      |
      | public static InetAddress getByName(String host)
      | throws UnknownHostException
      |
      | Determines the IP address of a host, given the host's name.
      | The host name can either be a machine name, such as "java.sun.com",
      | or a string representing its IP address, such as "206.26.48.100".
      |
      | Parameters:
      | host - the specified host, or null for the local host.

      Please note, that here null is strictly defined as the local host.

      The following test reveals that constructor SocketHandler() throws
      IllegalArgumentException if host and port properties are not defined.

      I think the spec should document such behavior.

      sckthndl002 log:

      # SocketHandler() unexpectedly throws
      # java.lang.IllegalArgumentException: Bad port: 0
      # TEST FAILED.

      sckthndl002.java source:

      // File: %W% %E%
      // Copyright %G% Sun Microsystems, Inc. All Rights Reserved

      file://package logging.SocketHandler.SocketHandler;

      import logging.share.*;

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

      public class sckthndl002 implements Testcase {

          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;
          private static LogManager logManager = LogManager.getLogManager();

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

              try {
                  SocketHandler sh = new SocketHandler();
              } catch (IOException exception) {
                  // OK, there is no listener
              } catch (Exception exception) {
                  out.println("# SocketHandler() unexpectedly throws");
                  out.println("# " + exception);
                  testFailed = true;
              }

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

          public static int run(String args[], PrintStream out) {
              Testcase testcase = new sckthndl002();
              return SecuredWrapper.execute(testcase,args,out);
          }

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

      Name: elR10090 Date: 02/01/2001


      This bug affects the following testbase_nsk test:
          nsk/logging/SocketHandler/SocketHandler/sckthndl002



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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: