From b8f10f69a9d9c4d351b75629cd209942aac6edf7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 6 May 2015 08:52:47 +0900 Subject: [PATCH] Fix binary compatibility for SmartApplicationListener Making sure that `GenericApplicationListenerAdapter` implements `SmartApplicationListener` again as older code may try to cast an instance to `SmartApplicationListener`. Issue: SPR-8201 --- .../context/event/GenericApplicationListenerAdapter.java | 7 ++++++- .../context/event/SourceFilteringListener.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java index 9362ac7875..ae0b4f5fb1 100644 --- a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java @@ -32,7 +32,7 @@ import org.springframework.util.Assert; * @since 3.0 * @see org.springframework.context.ApplicationListener#onApplicationEvent */ -public class GenericApplicationListenerAdapter implements GenericApplicationListener { +public class GenericApplicationListenerAdapter implements GenericApplicationListener, SmartApplicationListener { private final ApplicationListener delegate; @@ -67,6 +67,11 @@ public class GenericApplicationListenerAdapter implements GenericApplicationList } } + @Override + public boolean supportsEventType(Class eventType) { + return supportsEventType(ResolvableType.forType(eventType)); + } + @Override public boolean supportsSourceType(Class sourceType) { if (this.delegate instanceof SmartApplicationListener) { diff --git a/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java b/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java index 6143b48483..21a4b4c7a0 100644 --- a/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java +++ b/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java @@ -33,7 +33,7 @@ import org.springframework.core.ResolvableType; * @author Stephane Nicoll * @since 2.0.5 */ -public class SourceFilteringListener implements GenericApplicationListener { +public class SourceFilteringListener implements GenericApplicationListener, SmartApplicationListener { private final Object source; @@ -77,6 +77,11 @@ public class SourceFilteringListener implements GenericApplicationListener { return (this.delegate == null || this.delegate.supportsEventType(eventType)); } + @Override + public boolean supportsEventType(Class eventType) { + return supportsEventType(ResolvableType.forType(eventType)); + } + @Override public boolean supportsSourceType(Class sourceType) { return (sourceType != null && sourceType.isInstance(this.source));