Commons Logging
  1. Commons Logging
  2. LOGGING-35

Logging has a NPE when security prevents property reading

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.0.1
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      In LogFactoryImpl:

      // Identify the Log implementation class we will be using
      String logClassName = null;
      try

      { /** Read attributes **/ /** Read properties **/ /** Look for Log4J **/ /** Look for jdk1.4 **/ /** Use Default logger **/ }

      catch (SecurityException e) {
      }

      // Attempt to load the Log implementation class
      Class logClass = null;
      try {
      logClass = loadClass(logClassName);

      If a SecurityException occurs, then logClassName isn't ever set, and the
      loadClass
      method throws a NullPointerException.

      What to do?
      a) Throw the SecurityException instead. Better, because then the cause is at
      least clearer (than the NPE), but probably not what we want.

      b) Have the DefaultLogger setting occur outside of the "try". Better still, but
      then you loose any chance of getting log4j or jdk1.4, just because you aren't
      allowed to read system properties.

      c) Only wrap the getProperty calls in the try block. I think this is the best
      solution, but I'm not sure if any of the other code in there could raise a
      SecruityException.

        Activity

        Tim Vernum created issue -
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 7468 12340194
        Henri Yandell made changes -
        Key COM-43 LOGGING-35
        Component/s Logging [ 12311124 ]
        Project Commons [ 12310458 ] Commons Logging [ 12310484 ]
        Affects Version/s 1.0 Final [ 12311651 ]
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Henri Yandell made changes -
        Affects Version/s 1.0 Final [ 12311814 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Dennis Lundberg made changes -
        Fix Version/s 1.0.1 [ 12311824 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Tim Vernum
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development