Skip to content

Commit 253060c

Browse files
committed
Only expose ASM-driven method order if the methods match
Issue: SPR-14505
1 parent a9ae2c3 commit 253060c

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.
@@ -365,15 +365,20 @@ private Set<MethodMetadata> retrieveBeanMethodMetadata(SourceClass sourceClass)
365365
AnnotationMetadata asm =
366366
this.metadataReaderFactory.getMetadataReader(original.getClassName()).getAnnotationMetadata();
367367
Set<MethodMetadata> asmMethods = asm.getAnnotatedMethods(Bean.class.getName());
368-
Set<MethodMetadata> reflectionMethods = beanMethods;
369-
beanMethods = new LinkedHashSet<>();
370-
for (MethodMetadata asmMethod : asmMethods) {
371-
for (MethodMetadata reflectionMethod : reflectionMethods) {
372-
if (reflectionMethod.getMethodName().equals(asmMethod.getMethodName())) {
373-
beanMethods.add(reflectionMethod);
374-
break;
368+
if (asmMethods.size() >= beanMethods.size()) {
369+
Set<MethodMetadata> selectedMethods = new LinkedHashSet<>(asmMethods.size());
370+
for (MethodMetadata asmMethod : asmMethods) {
371+
for (MethodMetadata beanMethod : beanMethods) {
372+
if (beanMethod.getMethodName().equals(asmMethod.getMethodName())) {
373+
selectedMethods.add(beanMethod);
374+
break;
375+
}
375376
}
376377
}
378+
if (selectedMethods.size() == beanMethods.size()) {
379+
// All reflection-detected methods found in ASM method set -> proceed
380+
beanMethods = selectedMethods;
381+
}
377382
}
378383
}
379384
catch (IOException ex) {

0 commit comments

Comments
 (0)