Skip to content

Inferring an ApplicationListener's event type from a lambda or method reference [SPR-10675] #15303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jun 23, 2013 · 4 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 23, 2013

Nick Williams opened SPR-10675 and commented

This works:

@Service
public class MyListener {
    @Bean
    public ApplicationListener<Event1> myListener$listener1() {
        return new ApplicationListener<Event1>() {
            @Override
            public void onApplicationEvent(Event1 event1) {
                System.out.println("Received Event1.");
            }
        };
    }

    @Bean
    public ApplicationListener<Event2> myListener$listener2() {
        return new ApplicationListener<Event2>() {
            @Override
            public void onApplicationEvent(Event2 event1) {
                System.out.println("Received Event2.");
            }
        };
    }
}

These two variations do not:

@Service
public class MyListener {
    @Bean
    public ApplicationListener<Event1> myListener$listener1() {
        return (Event1 e) -> {
            System.out.println("Received Event1.");
        };
    }

    @Bean
    public ApplicationListener<Event2> myListener$listener2() {
        return (Event2 e) -> {
            System.out.println("Received Event2.");
        };
    }
}
@Service
public class MyListener {
    public void onEvent1(Event1 event1) {
        System.out.println("Received Event1.");
    }

    public void onEvent2(Event2 event2) {
        System.out.println("Received Event2.");
    }

    @Bean
    public ApplicationListener<Event1> myListener$listener1() {
        return this::onEvent1;
    }

    @Bean
    public ApplicationListener<Event2> myListener$listener2() {
        return this::onEvent2;
    }
}

With either of these last two, Spring never starts. The following output is logged:

13:32:49.106 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:273): Root WebApplicationContext: initialization started
13:32:49.109 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:524): Refreshing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy
13:32:49.215 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
13:32:49.217 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning
13:32:49.218 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210): Registering annotated classes: [class com.wrox.config.RootContextConfiguration]
13:32:49.512 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:233): JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
13:32:49.512 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.context.annotation.ClassPathBeanDefinitionScanner org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider.java:241): JSR-330 'javax.inject.Named' annotation found and supported for component scanning
13:32:49.807 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.<init>(AutowiredAnnotationBeanPostProcessor.java:140): JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
13:32:49.859 [RMI TCP Connection(3)-127.0.0.1]   INFO  com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.initialize(RootContextConfiguration.java:120): Setting up thread pool task scheduler with 20 threads.
13:32:49.922 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'rootContextConfiguration' of type [class com.wrox.config.RootContextConfiguration$$EnhancerByCGLIB$$45668b0d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
13:32:49.930 [RMI TCP Connection(3)-127.0.0.1]   INFO  com.wrox.config.RootContextConfiguration com.wrox.config.RootContextConfiguration.getAsyncExecutor(RootContextConfiguration.java:106): Configuring asynchronous method executor org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler@6f83de8a.
13:32:49.939 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerByCGLIB$$80f4fcd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
13:32:49.994 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerByCGLIB$$b4ccf16b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
13:32:50.034 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'messageSource' of type [class org.springframework.context.support.ReloadableResourceBundleMessageSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
13:32:50.175 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1445): Bean 'localValidatorFactoryBean' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
13:32:50.197 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:611): Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy
13:32:50.443 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.initialize(ExecutorConfigurationSupport.java:161): Initializing ExecutorService  'taskScheduler'
13:32:50.462 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.oxm.jaxb.Jaxb2Marshaller org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromPackages(Jaxb2Marshaller.java:484): Creating JAXBContext by scanning packages [com.wrox.site]
13:32:50.542 [RMI TCP Connection(3)-127.0.0.1]   ERROR org.springframework.web.context.ContextLoader org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319): Context initialization failed
java.lang.ClassCastException: org.springframework.context.event.ContextRefreshedEvent cannot be cast to com.wrox.site.Event1
	at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:496) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.0.M1.jar:4.0.0.M1]
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5210) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea]
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea]
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea]
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea]
	at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea]
	at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea]
	at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea]
	at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea]
13:32:50.563 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045): Closing Root WebApplicationContext: startup date [Sun Jun 23 13:32:49 CDT 2013]; root of context hierarchy
13:32:50.570 [RMI TCP Connection(3)-127.0.0.1]   WARN  org.springframework.web.context.support.AnnotationConfigWebApplicationContext org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1055): Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.ClassCastException: org.springframework.context.event.ContextClosedEvent cannot be cast to com.wrox.site.Event1
	at com.wrox.site.MyListener$$Lambda$3.onApplicationEvent(Unknown Source) ~[MyListener.class:?]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:344) ~[spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1052) [spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1013) [spring-context-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559) [spring-web-4.0.0.M1.jar:4.0.0.M1]
	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115) [spring-web-4.0.0.M1.jar:4.0.0.M1]
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4805) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5414) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1491) [catalina.jar:8.0.0-dev]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea]
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea]
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:468) [catalina.jar:8.0.0-dev]
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415) [catalina.jar:8.0.0-dev]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.0-dev]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0-ea]
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1465) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:75) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1306) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1398) [?:1.8.0-ea]
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) [?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.8.0-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0-ea]
	at java.lang.reflect.Method.invoke(Method.java:491) ~[?:1.8.0-ea]
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.8.0-ea]
	at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.8.0-ea]
	at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.8.0-ea]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0-ea]
	at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.8.0-ea]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.8.0-ea]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.8.0-ea]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.8.0-ea]
	at java.lang.Thread.run(Thread.java:724) [?:1.8.0-ea]
13:32:50.573 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:452): Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75c729d4: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,rootContextConfiguration,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,myListener,myListener$listener1,myListener$listener2,org.springframework.scheduling.annotation.ProxyAsyncConfiguration,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.scheduling.annotation.SchedulingConfiguration,org.springframework.context.annotation.internalScheduledAnnotationProcessor,messageSource,objectMapper,taskScheduler,localValidatorFactoryBean,methodValidationPostProcessor,jaxb2Marshaller]; root of factory hierarchy
13:32:50.573 [RMI TCP Connection(3)-127.0.0.1]   INFO  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:199): Shutting down ExecutorService 'taskScheduler'

It seems to me that this should work. Perhaps a tweak to the listener registry to detect the method argument type from lambdas and references, too, instead of just regular and anonymous classes.


Affects: 4.0 M1

Issue Links:

2 votes, 8 watchers

@spring-projects-issues
Copy link
Collaborator Author

Phil Webb commented

At a guess, I would say that GenericApplicationListenerAdapter is not working with lambdas.

@spring-projects-issues
Copy link
Collaborator Author

Nick Williams commented

Is this still planned for being fixed in Spring 4.2?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 7, 2015

Juergen Hoeller commented

If we're trying to support this along the lines of #17130, retrieving the declared type from the lambda-defined instance, we have no acceptable way to retrieve that information yet. See my comment on that issue: hacking into the JVM constant pool isn't really feasible there.

As an alternative, we may also try to introspect the method's return type declaration along the lines of #16146. That will obviously only work for factory methods, not for programmatically registered listener instances, and only if the factory method redeclares the generic event type.

Juergen

@philwebb
Copy link
Member

I think this has now been superseded by #23178 which has just been fixed for RC1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants