Fix: more vigorous handling of syntax for spring.autoconfigure.exclude - #2330
Fix: more vigorous handling of syntax for spring.autoconfigure.exclude#2330anenviousguest wants to merge 3 commits into
spring.autoconfigure.exclude#2330Conversation
| ], | ||
| webEnvironment = SpringBootTest.WebEnvironment.NONE | ||
| ) | ||
| @TestPropertySource(properties = ["spring.autoconfigure.exclude=someotherexclude"]) |
There was a problem hiding this comment.
basically, that's a replacement of the test which i removed from ExcludeAutoConfigurationsEnvironmentPostProcessorTest (see below).
Here, we have test property source, with our expectation that this will take priority over the same property defined via application-<profile>.properties which I also added
# Conflicts: # graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/ExcludeAutoConfigurationsEnvironmentPostProcessor.kt # graphql-dgs-spring-graphql/src/test/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/ExcludeAutoConfigurationsEnvironmentPostProcessorTest.kt
|
thanks @paulbakker - I pushed one more commit to fix linting errors. |
|
Hey @anenviousguest, first off thanks for the report and contribution! It seems that while this does fix your initial bug report, it also changes the underlying behavior of the exclude mechanism more broadly. As we have it implemented now, we join the value of Any opposition to just using a comma separated list instead of yaml array syntax? IIRC there are many pitfalls around using yaml array syntax for a variety of spring properties and comma separated lists avoid the headache. |
|
Thanks @jjacobs44 , this is a fair point. Ultimately, it would be your call as code owners, but please consider this:
Also I looked once again at #2032 - even there, the author complained that:
So, the expectation was based on SpringBoot contract - that WDYT? PS: to this one:
That's the work-around we are currently forced to use, but it's far from perfect because from ergonomics standpoint, arrays are easier to maintain. This particular property holds an array of fully qualified class names, so keeping it in a single string drastically reduces readability and makes it harder to grok the diff. Thanks. |
This fixes #2329
Pull request checklist
first
Pull Request type
Changes in this PR
In a nutshell - this PR makes
ExcludeAutoConfigurationsEnvironmentPostProcessordefer the retrieval ofspring.autoconfigure.excludeto Spring's binder instead of manually looping through available properties source and doing the guess work wrt syntax which was used for a property.As far as the Test Properties are concerned - there was a dedicated code in the
ExcludeAutoConfigurationsEnvironmentPostProcessorwhich was trying to ensure that those takes precedence - but yet again, this is rather the job of SpringBoot itself and not of DGS to make this happen. I checked #2032 which was describing the original issue with test properties not taking precedence and added a dedicatedSpringBootTestto illustrate that it should work without special handling on the side of DGS.