Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test that interceptors are dependent instances of intercepted beans #462

Merged
merged 1 commit into from
May 18, 2023

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented May 11, 2023

The test previously used a @PreDestroy callback declared on the interceptor to prove that the interceptor is destroyed when the intercepted bean is destroyed, which is incorrect. Interceptors cannot declare lifecycle callbacks for themselves, the @PreDestroy callback actually interposed on the destruction of the intercepted bean.

This commit uses a new dependent-scoped bean that is injected into the interceptor, which makes it a dependent instance of the interceptor. The new bean has a @PreDestroy callback for itself, which means we can verify that the new bean is destroyed when the intercepted bean is destroyed. Such chain of dependent instance destruction proves that the interceptor is indeed a dependent instance of the intercepted bean.

Fixes #454

The test previously used a `@PreDestroy` callback declared on the interceptor
to prove that the interceptor is destroyed when the intercepted bean is
destroyed, which is incorrect. Interceptors cannot declare lifecycle callbacks
for themselves, the `@PreDestroy` callback actually interposed on the destruction
of the intercepted bean.

This commit uses a new dependent-scoped bean that is injected into the interceptor,
which makes it a dependent instance of the interceptor. The new bean has
a `@PreDestroy` callback for itself, which means we can verify that the new bean
is destroyed when the intercepted bean is destroyed. Such chain of dependent
instance destruction proves that the interceptor is indeed a dependent instance
of the intercepted bean.
@Ladicek
Copy link
Contributor Author

Ladicek commented May 11, 2023

Draft until #454 is accepted.

Copy link
Contributor

@manovotn manovotn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants