Uploaded image for project: 'Commons Logging'
  1. Commons Logging
  2. LOGGING-22

NullPointerException in LogFactory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • 1.0.3
    • None
    • Operating System: All
      Platform: PC

    • 16457

    Description

      Trying to run this software on an EAServer, a NullPointerException is thrown in
      two different places within LogFactory.java. I was able to trace the problem
      in the source:
      1) private static LogFactory getCachedFactory(ClassLoader contextClassLoader)

      { LogFactory factory = null; if (contextClassLoader != null) factory = (LogFactory) factories.get(contextClassLoader); if (factory==null) factory = (LogFactory) factories.get(LogFactory.class.getClassLoader ()); return factory; }

      the factories.get(LogFactory.class.getClassLoader()) will cause a problem
      because LogFactory.class.GetClassLoader() is null (using jre 1.4) changing
      that part to a call to getContextClassLoader() would resolve this bug.

      2) in getFactory():

      // Fourth, try the fallback implementation class
      if (factory == null)

      { factory = newFactory(FACTORY_DEFAULT, LogFactory.class.getClassLoader()); }

      same deal here, replacing LogFactory.class.getClassLoader() with contextClass
      will fix.

      I don't know if there was a reason these were left as
      LogFactory.class.getClassLoader(), but getContextClassLoader(), will determine
      if this is the correct call to make (and it states that this is only
      appropriate in pre-jdk1.1), instead of just assuming it is the right call,
      causing NullPointerExceptions.

      Perhaps this wasn't noticed since it usually doesn't get to this fallback
      position, but on the application server, it does every time.

      Attachments

        Activity

          People

            Unassigned Unassigned
            philipm@sybase.com Philip Mitchell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: