-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Andy Wilkinson opened SPR-11788 and commented
I've been investigating a problem with some auto-configuration in Boot. I've boiled it down into a simple test case (see attached) that hopefully illustrates the problem.
The problem is that if a configuration class is imported twice and one of those imports is excluded due to an unmatched condition then the ordering of the imports matters. If the unconditional import is processed first then the import is honoured and the imported configuration is processed. However, if the conditional import is processed first then the import is skipped.
I've dug around in the code a bit and the behaviour's due to a configuration class only having a single importedBy. Referring to the test case, this means that when ConditionalConfiguration is processed first it is BeanProvidingConfiguration's importedBy and TrackedConditionEvaluator skips it. Similarly, when UnconditionalConfiguration is processed first it is BeanProvidingConfiguration's importedBy and the configuration is processed.
I'm not sure if this is a bug or if it's by design, but it does seem rather brittle. The behaviour that I would like is for all of a configuration's importers to be considered and if any of them are unconditional or have a matching condition then the imported configuration should be processed.
Affects: 4.0.4
Attachments:
- ImportsWithConditionsTests.java (3.49 kB)
Issue Links:
- Metadata provided by ImportAware ignores conditions and is dependent on the order of the configuration classes [SPR-12128] #16744 Metadata provided by ImportAware ignores conditions and is dependent on the order of the configuration classes
0 votes, 5 watchers