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

[logging] org.apache.commons.logging.impl.LogFactoryImpl does not provide enough information on an InvocationTargetException in the newInstance() method.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0.3
    • 1.0.4
    • None
    • Operating System: Solaris
      Platform: Sun

    • 26598

    Description

      Using version 1-0-3 I was getting an
      org.apache.commons.logging.LogConfigurationException while attempting to
      retrieve a Log instance from the LogFactory. This LogConfigurationException was
      wrapping an InvocationTargetException from the newInstance() method in
      org.apache.commons.logging.impl.LogFactoryImpl. An InvocationTargetException
      does not provide any information regarding the cause of the exception in its'
      stack trace so I had a difficult time determining the true cause of the error
      (A ClassNotFoundException).

      I would suggest adding a special case to the existing catch clause in
      newInstance() to catch an InvocationTargetException and throw a new
      LogConfigurationExeption constructed with the cause (not the
      InvocationTargetException object).

      The following would be the new catch clause:

      } catch (InvocationTargetException e)

      { throw new LogConfigurationException(e.getCause()); } catch (Throwable t) { throw new LogConfigurationException(t); }

      The modified newInstance() method would look like this:

      protected Log newInstance(String name) throws LogConfigurationException {

      Log instance = null;
      try {
      Object params[] = new Object[1];
      params[0] = name;
      instance = (Log) getLogConstructor().newInstance(params);
      if (logMethod != null) { params[0] = this; logMethod.invoke(instance, params); }
      return (instance);
      } catch (InvocationTargetException e) { throw new LogConfigurationException(e.getCause()); }

      catch (Throwable t)

      { throw new LogConfigurationException(t); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            bcurnow@gfs.com Brian Curnow
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: