Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2159

NPE when reading method which doesn't have @Observes in ABD

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.0.Alpha17
    • 3.0.0.Alpha16
    • Extensions
    • None

      When you are doing in your extension something like:

         void observesABD(@Observes AfterBeanDiscovery abd) throws NoSuchMethodException {
            
              Method melonMethod = FruitObserver.class.getMethod("observesMelon", Melon.class);
              abd.addObserverMethod().read(melonMethod) ...
      
      } 
      

      and "observesMelon" doesn't have any @Observes param then Weld fails with NPE:

      java.lang.NullPointerException
      	at org.jboss.weld.bootstrap.events.builder.ObserverMethodConfiguratorImpl.read(ObserverMethodConfiguratorImpl.java:94)
      	at org.jboss.cdi.tck.tests.extensions.configurators.observerMethod.AfterBeanDiscoveryObserver.observesABD(AfterBeanDiscoveryObserver.java:62)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:96)
      	at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:86)
      	at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:129)
      	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:344)
      	at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
      	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:322)
      	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:300)
      	at org.jboss.weld.util.Observers.notify(Observers.java:140)
      	at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:300)
      	at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:288)
      	at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:165)
      	at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:159)
      	at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
      	at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
      	at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:74)
      	at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:419)
      	at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
      	at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:74
      

              mkouba@redhat.com Martin Kouba
              tremes1@redhat.com Tomas Remes
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: