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

Improve exception message when trying to change observed type of existing observer method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Minor Minor
    • 3.0.0.Beta1
    • 3.0.0.Alpha16
    • None
    • None

      Currently if I have following observer:

      void observesApple(@Observes Pear apple)
      

      and I try to change it within POM as follows:

          void observesPearPOM(@Observes ProcessObserverMethod<Pear, FirstFruitObserver> event) {
              // set observed type to Apple
              event.configureObserverMethod().observedType(Apple.class);
          }
      

      I will get following exception:

      java.lang.IllegalArgumentException: argument type mismatch
      	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.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:322)
      	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:300)
      	at org.jboss.weld.bootstrap.events.builder.ObserverMethodConfiguratorImpl.lambda$read$47(ObserverMethodConfiguratorImpl.java:146)
      	at org.jboss.weld.bootstrap.events.builder.ObserverMethodBuilderImpl$NotificationCallback.notify(ObserverMethodBuilderImpl.java:170)
      	at org.jboss.weld.bootstrap.events.builder.ObserverMethodBuilderImpl$ImmutableObserverMethod.notify(ObserverMethodBuilderImpl.java:142)
      	at org.jboss.weld.util.Observers.notify(Observers.java:138)
      	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:147)
      	at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:623)
      	at org.jboss.weld.util.ForwardingBeanManager.fireEvent(ForwardingBeanManager.java:101)
      

      This is likely expected but I think we should improve expcetion message to be more clear.

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

                Created:
                Updated:
                Resolved: