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
{{ message }}
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Filter ContextCustomizerFactory implementations that are only necessary at build time #1242
At build time, the processing of @SpringBootTest registers the necessary infrastructure to parse SomeConfiguration. At runtime, this process runs again (because it is part of SpringBootTestContextBootstrapper, via ImportsContextCustomizer).
Parsing configuration classes in a native image should not happen as it was done already at build time.
Deliverables
This task is to validate that the right AOT infrastructure is generated with such a test and to prevent it from happening again at runtime.
There might be other ContextCustomizer implementations that are running twice and should be handled the same way.
Everything goes in the direction of being able to swap the TestContextBootstrapper that the test uses. We won't be able to get that short term so rewriting spring.factories to remove org.springframework.boot.test.context.ImportsContextCustomizerFactory could be one good option.
changed the title [-]Investigate how to support use of ContextCustomizer[/-][+]Filter ContextCustomizerFactory implementations that are only necessary at build time[/+]on Nov 15, 2021
Everything goes in the direction of being able to swap the TestContextBootstrapper that the test uses.
Indeed, that may be the most robust solution in the end.
We won't be able to get that short term so rewriting spring.factories to remove org.springframework.boot.test.context.ImportsContextCustomizerFactory could be one good option.
I thought about that as well, but the thing is that the context customizers have to be present/instantiated/registered in order for the MergedContextConfiguration to do its job as the key for the ContextCache.
@sbrannen can you please give us a status update of what you've tried so that I don't duplicate the effort?
I didn't have a solution in place. Rather, I was investigating/contemplating possible solutions.
One thing I was considering was "caching" the calculated ContextCustomizerKey (or what it needs as input) for the ImportsContextCustomizer at build time, making that available via some generated factory (or similar approach), and then implementing a native substitution for the ImportsContextCustomizer constructor that (re)builds the ContextCustomizerKey from input retrieved from the generated factory -- effectively bypassing the ContextCustomizerKey#determineImports(Set<Annotation>, Class<?>) logic within the native image.
Activity
sdeleuze commentedon Nov 11, 2021
This is breaking
petclinic-jdbctests (at least) so let's try to solve it for RC1.snicoll commentedon Nov 15, 2021
@sbrannen can you please give us a status update of what you've tried so that I don't duplicate the effort?
snicoll commentedon Nov 15, 2021
Everything goes in the direction of being able to swap the
TestContextBootstrapperthat the test uses. We won't be able to get that short term so rewritingspring.factoriesto removeorg.springframework.boot.test.context.ImportsContextCustomizerFactorycould be one good option.[-]Investigate how to support use of ContextCustomizer[/-][+]Filter ContextCustomizerFactory implementations that are only necessary at build time[/+]sbrannen commentedon Nov 15, 2021
Indeed, that may be the most robust solution in the end.
I thought about that as well, but the thing is that the context customizers have to be present/instantiated/registered in order for the
MergedContextConfigurationto do its job as the key for theContextCache.sbrannen commentedon Nov 15, 2021
I didn't have a solution in place. Rather, I was investigating/contemplating possible solutions.
One thing I was considering was "caching" the calculated
ContextCustomizerKey(or what it needs as input) for theImportsContextCustomizerat build time, making that available via some generated factory (or similar approach), and then implementing a native substitution for theImportsContextCustomizerconstructor that (re)builds theContextCustomizerKeyfrom input retrieved from the generated factory -- effectively bypassing theContextCustomizerKey#determineImports(Set<Annotation>, Class<?>)logic within the native image.snicoll commentedon Nov 15, 2021
Let's follow-up on #1262 for the cache key problem.
Ignore ContextCustomizerFactory implementations that are runtime only