Uploaded image for project: 'JBoss Transaction Manager'
  1. JBoss Transaction Manager
  2. JBTM-641

com.arjuna.common.util.logging.LogFactory#loadFactory does not handle properly null argument

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.9.0
    • 4.8.0
    • JTS
    • None
    • Hide

      No workaround. I used the "simple" log system but this is not satisfactory.

      Show
      No workaround. I used the "simple" log system but this is not satisfactory.

      com.arjuna.common.util.logging.LogFactory#setupLogSystem makes calls to
      com.arjuna.common.util.logging.LogFactory#loadFactory("com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory", null) when the jakarta log system is selected.
      When the logger class name argument is nullm the loadfactory will try to instanciate the "com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory" class with a no-arg constructor and this class does NOT have a
      no-arg ctor.
      private static LogFactoryInterface loadFactory(String classname, String arg) throws LogConfigurationException
      {
      try {
      Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(classname);
      LogFactoryInterface logFactoryInterface = null;
      if(arg == null)

      { // THIS WILL FAIL AS "com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory" AS NO SUCH CTOR logFactoryInterface = (LogFactoryInterface)factoryClass.newInstance(); }

      else {
      Constructor ctor = factoryClass.getConstructor(new Class[]

      { String.class});
      logFactoryInterface = (LogFactoryInterface)ctor.newInstance(arg);
      }
      return logFactoryInterface;
      } catch (Exception e) { throw new LogConfigurationException(e); }
      }

      Proposed fix: The fix is to simply always forward the argument to the String arg ctor - with a null arg, the JakartaLogFactory will properly
      use the default logger from commons.logging

      private static LogFactoryInterface loadFactory(String classname, String arg) throws LogConfigurationException
      {
      try {
      Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(classname);
      LogFactoryInterface logFactoryInterface = null;
      Constructor ctor = factoryClass.getConstructor(new Class[] { String.class}

      );
      logFactoryInterface = (LogFactoryInterface)ctor.newInstance(arg);
      return logFactoryInterface;
      } catch (Exception e)

      { throw new LogConfigurationException(e); }

      }

              rhn-engineering-jhallida Jonathan Halliday
              jogoussard1 Jacques-Olivier Goussard (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: