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.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.0.4
    • Labels:
      None
    • Environment:

      Operating System: Solaris
      Platform: Sun

      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); }

      }

        Activity

        Hide
        Dennis Lundberg added a comment -

        Since InvocationTargetException.getCause() was introduced in JDK 1.4 we should
        use InvocationTargetException.getTargetException() instead to retain
        compatibility with earlier JDKs.

        Show
        Dennis Lundberg added a comment - Since InvocationTargetException.getCause() was introduced in JDK 1.4 we should use InvocationTargetException.getTargetException() instead to retain compatibility with earlier JDKs.
        Hide
        Craig McClanahan added a comment -

        Fixed in nightly build 20040307 (and the upcoming 1.0.4 release).

        Show
        Craig McClanahan added a comment - Fixed in nightly build 20040307 (and the upcoming 1.0.4 release).

          People

          • Assignee:
            Unassigned
            Reporter:
            Brian Curnow
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development