From c11a1957f3250f1e6e418ef147b293eb129374ec Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Sun, 12 May 2019 16:22:24 +0100 Subject: [PATCH] Fix deprecation in StateMachineAnnotationPostProcessor - As AnnotationUtils.getAnnotations from framework is deprecated from 5.2 move over to MergedAnnotations api. - Relates to #765 --- .../StateMachineAnnotationPostProcessor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineAnnotationPostProcessor.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineAnnotationPostProcessor.java index d6248143..63b6b0b2 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineAnnotationPostProcessor.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 the original author or authors. + * Copyright 2015-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. @@ -43,6 +43,8 @@ import org.springframework.context.Lifecycle; import org.springframework.context.SmartLifecycle; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.core.annotation.MergedAnnotation; +import org.springframework.core.annotation.MergedAnnotations; import org.springframework.statemachine.annotation.OnEventNotAccepted; import org.springframework.statemachine.annotation.OnExtendedStateChanged; import org.springframework.statemachine.annotation.OnStateChanged; @@ -273,13 +275,11 @@ public class StateMachineAnnotationPostProcessor implements BeanPostProcessor, B return name; } - private List getAnnotationChain(Method method, Class annotationType) { - Annotation[] annotations = AnnotationUtils.getAnnotations(method); List annotationChain = new LinkedList(); - Set visited = new HashSet(); - for (Annotation ann : annotations) { - this.recursiveFindAnnotation(annotationType, ann, annotationChain, visited); + Set visited = new HashSet<>(); + for (MergedAnnotation mergedAnnotation : MergedAnnotations.from(method)) { + recursiveFindAnnotation(annotationType, mergedAnnotation.synthesize(), annotationChain, visited); if (annotationChain.size() > 0) { Collections.reverse(annotationChain); return annotationChain;