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

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.8.0
    • Fix Version/s: 4.9.0
    • Component/s: JTS
    • Labels:
      None
    • Environment:

      standalone (J2SE) use of jbossts-jta-4.8.0.GA.zip

    • Workaround Description:
      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.

      Description

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

      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                jhalliday Jonathan Halliday
                Reporter:
                jogoussard1 Jacques-Olivier Goussard
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: