Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

ImportAware links are being called inconsistently #1079

Closed
snicoll opened this issue Sep 24, 2021 · 2 comments
Closed

ImportAware links are being called inconsistently #1079

snicoll opened this issue Sep 24, 2021 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Contributor

snicoll commented Sep 24, 2021

ImportAwareLinksDiscoverer is relying on ResolvableType to figure out whether the bean type implements ImportAware. Unfortunately, some bean definitions doesn't have one so we should fallback to the beanClassName if necessary.

@snicoll snicoll added the type: bug A general bug label Sep 24, 2021
@snicoll snicoll added this to the 0.11.0-M1 milestone Sep 24, 2021
@snicoll snicoll changed the title ImportAware link is not detected if the bean definition does not have a ResolvableType ImportAware links are being called inconsistently Sep 27, 2021
@snicoll
Copy link
Contributor Author

snicoll commented Sep 27, 2021

On a second look, this is rather a different problem. We're taking the parent configuration class as the import link whereas framework really means the import semantic. So, for instance, if you have a inner class of a configuration class that's import aware, the AOT engine will honor the callback whereas the JVM would not (as the inner class wasn't @Import'ed).

Unfortunately, there's no API to access that information as the ImportStack is computed at runtime. We will have to change something in our override of ConfigurationClassParser for this.

@snicoll snicoll self-assigned this Sep 28, 2021
snicoll added a commit that referenced this issue Sep 28, 2021
This commit refines our strategy to invoke ImportAware callbacks to use
framework's ImportRegistry rather than running our own logic. At build
time, we know requested the importing class of each bean that is
import aware, and store that in a registry of our own. This is latter
used to write the links that ImportAwareInvoker uses at build time.

ImportAwareInvoker has also been refined to not invoke the callback if
no import class is registered. Previously, it was throwing an innacurate
exception as this is possible for an import aware configuration class to
be processed directly (i.e. without a corresponding import arrangement).

Closes gh-1079
@snicoll
Copy link
Contributor Author

snicoll commented Sep 28, 2021

Fixed by 1d055a1

@snicoll snicoll closed this as completed Sep 28, 2021
snicoll added a commit that referenced this issue Sep 28, 2021
This commit refines our strategy to invoke ImportAware callbacks to use
framework's ImportRegistry rather than running our own logic. At build
time, we know requested the importing class of each bean that is
import aware, and store that in a registry of our own. This is latter
used to write the links that ImportAwareInvoker uses at build time.

ImportAwareInvoker has also been refined to not invoke the callback if
no import class is registered. Previously, it was throwing an innacurate
exception as this is possible for an import aware configuration class to
be processed directly (i.e. without a corresponding import arrangement).

Closes gh-1079
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Development

No branches or pull requests

1 participant