Only expose ASM-driven method order if the methods match
Issue: SPR-14505
This commit is contained in:
parent
a9ae2c3402
commit
253060c21c
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -365,16 +365,21 @@ class ConfigurationClassParser {
|
||||||
AnnotationMetadata asm =
|
AnnotationMetadata asm =
|
||||||
this.metadataReaderFactory.getMetadataReader(original.getClassName()).getAnnotationMetadata();
|
this.metadataReaderFactory.getMetadataReader(original.getClassName()).getAnnotationMetadata();
|
||||||
Set<MethodMetadata> asmMethods = asm.getAnnotatedMethods(Bean.class.getName());
|
Set<MethodMetadata> asmMethods = asm.getAnnotatedMethods(Bean.class.getName());
|
||||||
Set<MethodMetadata> reflectionMethods = beanMethods;
|
if (asmMethods.size() >= beanMethods.size()) {
|
||||||
beanMethods = new LinkedHashSet<>();
|
Set<MethodMetadata> selectedMethods = new LinkedHashSet<>(asmMethods.size());
|
||||||
for (MethodMetadata asmMethod : asmMethods) {
|
for (MethodMetadata asmMethod : asmMethods) {
|
||||||
for (MethodMetadata reflectionMethod : reflectionMethods) {
|
for (MethodMetadata beanMethod : beanMethods) {
|
||||||
if (reflectionMethod.getMethodName().equals(asmMethod.getMethodName())) {
|
if (beanMethod.getMethodName().equals(asmMethod.getMethodName())) {
|
||||||
beanMethods.add(reflectionMethod);
|
selectedMethods.add(beanMethod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selectedMethods.size() == beanMethods.size()) {
|
||||||
|
// All reflection-detected methods found in ASM method set -> proceed
|
||||||
|
beanMethods = selectedMethods;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
logger.debug("Failed to read class file via ASM for determining @Bean method order", ex);
|
logger.debug("Failed to read class file via ASM for determining @Bean method order", ex);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue