From 1d59e52f118fe36b1321bc51e58759d8cd93c377 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 18 Aug 2018 12:05:39 +0200 Subject: [PATCH] EventListenerMethodProcessor accepts internal configuration classes Issue: SPR-17160 --- .../context/event/EventListenerMethodProcessor.java | 3 ++- .../context/event/AnnotationDrivenEventListenerTests.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java index 7ed65567572..191f08925b2 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java @@ -45,6 +45,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; /** @@ -196,7 +197,7 @@ public class EventListenerMethodProcessor */ private static boolean isSpringContainerClass(Class clazz) { return (clazz.getName().startsWith("org.springframework.") && - !AnnotatedElementUtils.isAnnotated(clazz, Component.class)); + !AnnotatedElementUtils.isAnnotated(ClassUtils.getUserClass(clazz), Component.class)); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index a53003aaecb..190771c6af7 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -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. @@ -951,7 +951,7 @@ public class AnnotationDrivenEventListenerTests { } - @Component + @Configuration static class OrderedTestListener extends TestEventListener { public final List order = new ArrayList<>();