Closed
Description
Armand Beuvens opened SPR-13852 and commented
After investigation on some issues on non detected circular imports inside Java configuration classes, it seems that there is a bug inside the contains method of the inner class ImportStack of the class ConfigurationClassParser:
@Override
public boolean contains(Object elem) {
ConfigurationClass configClass = (ConfigurationClass) elem;
Comparator<ConfigurationClass> comparator = new Comparator<ConfigurationClass>() {
@Override
public int compare(ConfigurationClass first, ConfigurationClass second) {
return (first.getMetadata().getClassName().equals(second.getMetadata().getClassName()) ? 0 : 1);
}
};
return (Collections.binarySearch(this, configClass, comparator) != -1);
}
The bianrySearch method of Collections is called without sorting the collection before which can lead to undefined results.
Affects: 4.2.3
Issue Links:
- Do not fail with a circular @Import error caused by an @ComponentScan [SPR-14517] #19086 Do not fail with a circular
@Import
error caused by an@ComponentScan