You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
That code seems to be rather outdated since ConfigurationClass.equals is based on class name equivalence these days anyway. So I'm simply removing it in favor of the standard contains implementation there.
I'm also changing the base class to java.util.ArrayDeque (JDK 6+ which is alright with us these days) in favor of the generally outdated java.util.Stack.
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:
The bianrySearch method of Collections is called without sorting the collection before which can lead to undefined results.
Affects: 4.2.3
Issue Links:
@Import
error caused by an@ComponentScan
Referenced from: commits e14c2de, 77b8f4d
The text was updated successfully, but these errors were encountered: