From 48c5b1e373d9d249cbfc68010346933a5b3e0c59 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 25 Jan 2019 15:44:43 +0100 Subject: [PATCH] ApplicationListenerMethodAdapter uses target method for order lookup Fixes #22307 (cherry picked from commit d0033f12d02f7517f8b756fed8914f335c88e8b5) --- .../event/ApplicationListenerMethodAdapter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index ee8d708cd4..0e35089a5a 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -94,11 +94,10 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe EventListener ann = AnnotatedElementUtils.findMergedAnnotation(this.targetMethod, EventListener.class); this.declaredEventTypes = resolveDeclaredEventTypes(method, ann); this.condition = (ann != null ? ann.condition() : null); - this.order = resolveOrder(method); + this.order = resolveOrder(this.targetMethod); } - - private List resolveDeclaredEventTypes(Method method, @Nullable EventListener ann) { + private static List resolveDeclaredEventTypes(Method method, @Nullable EventListener ann) { int count = method.getParameterCount(); if (count > 1) { throw new IllegalStateException( @@ -123,11 +122,12 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe return Collections.singletonList(ResolvableType.forMethodParameter(method, 0)); } - private int resolveOrder(Method method) { + private static int resolveOrder(Method method) { Order ann = AnnotatedElementUtils.findMergedAnnotation(method, Order.class); return (ann != null ? ann.value() : 0); } + /** * Initialize this instance. */