Properly analyze Java 9 class cast messages for lambda event listeners

Issue: SPR-16435
This commit is contained in:
Juergen Hoeller
2018-01-30 15:53:58 +01:00
parent 4f28c28287
commit 89d2bd954a
2 changed files with 42 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -472,6 +472,30 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen
context.close();
}
@Test
public void lambdaAsListenerWithJava8StyleClassCastMessage() {
StaticApplicationContext context = new StaticApplicationContext();
ApplicationListener<ApplicationEvent> listener =
event -> { throw new ClassCastException(event.getClass().getName()); };
context.addApplicationListener(listener);
context.refresh();
context.publishEvent(new MyEvent(context));
context.close();
}
@Test
public void lambdaAsListenerWithJava9StyleClassCastMessage() {
StaticApplicationContext context = new StaticApplicationContext();
ApplicationListener<ApplicationEvent> listener =
event -> { throw new ClassCastException("spring.context/" + event.getClass().getName()); };
context.addApplicationListener(listener);
context.refresh();
context.publishEvent(new MyEvent(context));
context.close();
}
@Test
public void beanPostProcessorPublishesEvents() {
GenericApplicationContext context = new GenericApplicationContext();