Properly analyze Java 9 class cast messages for lambda event listeners
Issue: SPR-16435
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user