Skip to content

Commit f7c3b81

Browse files
committed
Only expose ASM-driven method order if the methods match
Issue: SPR-14505 (cherry picked from commit 253060c)
1 parent 155bbb8 commit f7c3b81

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -366,15 +366,20 @@ private Set<MethodMetadata> retrieveBeanMethodMetadata(SourceClass sourceClass)
366366
AnnotationMetadata asm =
367367
this.metadataReaderFactory.getMetadataReader(original.getClassName()).getAnnotationMetadata();
368368
Set<MethodMetadata> asmMethods = asm.getAnnotatedMethods(Bean.class.getName());
369-
Set<MethodMetadata> reflectionMethods = beanMethods;
370-
beanMethods = new LinkedHashSet<MethodMetadata>();
371-
for (MethodMetadata asmMethod : asmMethods) {
372-
for (MethodMetadata reflectionMethod : reflectionMethods) {
373-
if (reflectionMethod.getMethodName().equals(asmMethod.getMethodName())) {
374-
beanMethods.add(reflectionMethod);
375-
break;
369+
if (asmMethods.size() >= beanMethods.size()) {
370+
Set<MethodMetadata> selectedMethods = new LinkedHashSet<MethodMetadata>(asmMethods.size());
371+
for (MethodMetadata asmMethod : asmMethods) {
372+
for (MethodMetadata beanMethod : beanMethods) {
373+
if (beanMethod.getMethodName().equals(asmMethod.getMethodName())) {
374+
selectedMethods.add(beanMethod);
375+
break;
376+
}
376377
}
377378
}
379+
if (selectedMethods.size() == beanMethods.size()) {
380+
// All reflection-detected methods found in ASM method set -> proceed
381+
beanMethods = selectedMethods;
382+
}
378383
}
379384
}
380385
catch (IOException ex) {

0 commit comments

Comments
 (0)