[
https://issues.jboss.org/browse/WELD-870?page=com.atlassian.jira.plugin.s...
]
Dan Allen commented on WELD-870:
--------------------------------
This Arquillian test proves that injection points on observer methods are not validated on
startup (I'm assuming the same goes for producer methods).
{code:java}
public class Observer {
// there is no bean for File
public void observe(@Observes String event, File file) {}
}
{code}
{code:java}
@RunWith(Arquillian.class)
public class ObserverMethodParameterInjectionValidationTest {
@Deployment
public static JavaArchive getDeployment() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addClass(Observer.class);
}
@Test
public void testDeployment() {
Assert.fail("Excepted deployment error: " +
"'Unsatisfied dependencies for type [File] with qualifiers [@Default]
on observer method injection point'");
}
/**
* This test should not run, but if it does, it shows Weld reporting the ambiguous
error in WELD-870:
* WELD-001324 Argument bean must not be null
*/
@Test
public void testNullInjectionOnObserverMethod(BeanManager beanManager) {
beanManager.fireEvent("message");
}
}
{code}
Add injection point information to exception message when injection
into observer fails
---------------------------------------------------------------------------------------
Key: WELD-870
URL:
https://issues.jboss.org/browse/WELD-870
Project: Weld
Issue Type: Enhancement
Components: Events
Affects Versions: 1.1.0.Final
Reporter: Dan Allen
Injections that fail when an observer method is invoked are massively hard to track down.
Here's the information you get:
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be
null
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:714)
at
org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:187)
at
org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
at
org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
at
org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222)
at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:619)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:613)
I expect to see the type and qualifiers at the failing injection point.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira