Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.10
-
Fix Version/s: 2.11.1
-
Component/s: PicoContainer (Java), PicoContainer Gems
-
Labels:None
-
Environment:PicoContainer 2.10.2.
-
Testcase included:yes
-
Number of attachments :
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.
null swapped for new Object[0].
Other suggestion to null-check in monitors, not implemented as there are no remaining examples in codebase that could pass null. At least in Pico's source.
thx.