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

LOGGING APIs: Logger.logrb() methods don't throw MissingResourceException

XMLWordPrintable

    • tiger
    • generic, sparc
    • generic, solaris_7
    • Verified



      Name: abR10010 Date: 09/07/2001



      The Logging APIs specification for all the Logger.logrb(...) methods says:

      "...
      Throws:
             java.util.MissingResourceException - if no suitable ResourceBundle can be found.
      ..."

      However, the NSK logrbTest shows that

      Logger.logrb(Level level,
                   String sourceClass,
                   String sourceMethod,
                   String source bundleName,
                   String msg)

      method does not throw expected MissingResourceException while execution under
      the engineering JDK build with the logging API changes according
      to RFE's
       
        4487060 logging: inferring caller information should be done lazily
        4487045 logging: improved error handling
        4487041 logging: more fully support hierarchical naming
       
      The same behavior is observed for all the Logger.logrb(...) methods
      from the Logger class.


      See log for logrbTest:

      % .../java/dest/jdk1.4.0beta-b75-graham/solsparc logrbTest
      ## FAILURE: Logger.logrb() method does NOT throw MissingResourceException
      # when ResorceBundleName is empty string!
      ## FAILURE: Logger.logrb() method does NOT throw MissingResourceException
      # when ResorceBundleName corresponds to non-existent ResorceBundle!
      ## logrbTest FAILED

      Please note that the JDK build 1.4.0-beta3-b78 (without the logging API changes)
      passes this test.

      The logrbTest source:
      ===============================================================================
      import java.util.logging.*;
      import java.io.*;
      import java.util.*;

      public class logrbTest {
          final static String testLoggerName = "logrbTest";
          static Logger testLogger = Logger.getLogger(testLoggerName);

          public static void main (String args[]) {
              System.exit(95 + run(args, System.out));
          }

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

              int STATUS_PASSED = 0;
              int STATUS_FAILED = 2;
              int testResult = STATUS_PASSED;

              testLogger.setLevel(Level.ALL);
              
              String resorceBundleName = "";
              try {
                  testLogger.logrb
                      (Level.INFO, "Source Class", "Source Method", resorceBundleName, "Message to log");
                  out.println
                      ("## FAILURE: Logger.logrb() method does NOT throw MissingResourceException");
                  out.println
                      ("# when ResorceBundleName is empty string!");
                  testResult = STATUS_FAILED;
              }
              catch (MissingResourceException mre) {
                  // PASSED: expected exception is thrown
              }
              catch (Throwable thrown) {
                  out.println
                      ("## FAILURE: Logger.logrb() method throws unexpected Exception");
                  out.println
                      ("# when ResorceBundleName is empty string:\n" + thrown);
                  testResult = STATUS_FAILED;
              }

              resorceBundleName = "Non-existent ResorceBundle";
              try {
                  testLogger.logrb
                      (Level.INFO, "Source Class", "Source Method", resorceBundleName, "Message to log");
                  out.println
                      ("## FAILURE: Logger.logrb() method does NOT throw MissingResourceException");
                  out.println
                      ("# when ResorceBundleName corresponds to non-existent ResorceBundle!");
                  testResult = STATUS_FAILED;
              }
              catch (MissingResourceException mre) {
                  // PASSED: expected exception is thrown
              }
              catch (Throwable thrown) {
                  out.println
                      ("## FAILURE: Logger.logrb() method throws unexpected Exception");
                  out.println
                      ("# when ResorceBundleName corresponds to non-existent ResorceBundle:\n"
                      + thrown);
                  testResult = STATUS_FAILED;
              }

              if ( testResult == STATUS_FAILED ) {
                  out.println("## logrbTest FAILED");
              }
              else {
                  out.println("-> logrbTest PASSED");
              }
              return testResult;
          }
      }
      ===============================================================================

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

            caustinsunw Calvin Austin (Inactive)
            bondsunw Bond Bond (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: