PicoContainer
  1. PicoContainer
  2. PICO-372

Can't use SetterInjection with Log4JComponentMonitor

    Details

    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      Using SetterInjection with a Log4JComponentMonitor yields the following exception.

      java.lang.NullPointerException
        at org.picocontainer.monitors.ComponentMonitorHelper.parmsToString(ComponentMonitorHelper.java:43)
        at org.picocontainer.gems.monitors.Log4JComponentMonitor.instantiated(Log4JComponentMonitor.java:158)
        at org.picocontainer.injectors.IterativeInjector.makeInstance(IterativeInjector.java:205)
        at org.picocontainer.injectors.IterativeInjector.access$100(IterativeInjector.java:35)
        at org.picocontainer.injectors.IterativeInjector$2.run(IterativeInjector.java:144)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:274)
        at org.picocontainer.injectors.IterativeInjector.getComponentInstance(IterativeInjector.java:150)
        at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:689)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:638)
        at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:663)
        ...
      

      That's because IterativeInjector passes null for the argument array, which Log4JComponentMonitor doesn't handle.

      componentMonitor.instantiated(container,
                                    IterativeInjector.this,
                                    constructorToUse,
                                    componentInstance,
                                    null,
                                    System.currentTimeMillis() - startTime);
      

      I think IterativeInjector should pass an empty array, and Log4JComponentAdapter might handle null just in case. Attached tests cover both places.

        People

        • Assignee:
          Paul Hammant
          Reporter:
          Ronald Blaschke
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: