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

Revise the IntegrationComponentSpec.get() API to disallow to be called from end-user code #8586

Closed
artembilan opened this issue Mar 27, 2023 · 0 comments · Fixed by #8594
Closed

Comments

@artembilan
Copy link
Member

The IntegrationComponentSpec implements a FactoryBean and we usually don't call its getObject() in the target project.
We rather rely on the Spring Framework dependency injection lifecylce.
The IntegrationComponentSpec.get() manual call may lead the component to the state where it is not fully initialized.
The Java DSL API and the framework by itself is able to deal properly with IntegrationComponentSpec as a bean as it can deal with FactoryBean.

Related issue: #2995

@artembilan artembilan added this to the Backlog milestone Mar 27, 2023
@artembilan artembilan self-assigned this Apr 12, 2023
@artembilan artembilan modified the milestones: Backlog, 6.1.0-RC1 Apr 12, 2023
artembilan added a commit to artembilan/spring-integration that referenced this issue Apr 12, 2023
Fixes spring-projects#8586

The `IntegrationComponentSpec` is not a plain wrapper around single component.
Sometimes it comes with several components where all of them must be registered
as beans.
If `IntegrationComponentSpec.get()` is called from end-user code, we may lose
other related components, for example filters in the `FileInboundChannelAdapterSpec`.

* Deprecate `IntegrationComponentSpec.get()` with no-op for end-user,
rather encourage to leave it as is and let the framework take care about its lifecycle
and related components registration
* Fix `IntegrationComponentSpec` logic to deal as a simple `FactoryBean` instead of
extra overhead via `AbstractFactoryBean`
* Use `IntegrationComponentSpec.getObject()` in the framework code where `get()` was called
* Fix tests to expose `IntegrationComponentSpec` as beans instead of previously called `get()`
* Some other clean up and typos fixes in the affected classes
* Document the change
garyrussell added a commit that referenced this issue Apr 13, 2023
* GH-8586: Deprecate IntegrationComponentSpec.get()

Fixes #8586

The `IntegrationComponentSpec` is not a plain wrapper around single component.
Sometimes it comes with several components where all of them must be registered
as beans.
If `IntegrationComponentSpec.get()` is called from end-user code, we may lose
other related components, for example filters in the `FileInboundChannelAdapterSpec`.

* Deprecate `IntegrationComponentSpec.get()` with no-op for end-user,
rather encourage to leave it as is and let the framework take care about its lifecycle
and related components registration
* Fix `IntegrationComponentSpec` logic to deal as a simple `FactoryBean` instead of
extra overhead via `AbstractFactoryBean`
* Use `IntegrationComponentSpec.getObject()` in the framework code where `get()` was called
* Fix tests to expose `IntegrationComponentSpec` as beans instead of previously called `get()`
* Some other clean up and typos fixes in the affected classes
* Document the change

* * Revert `ObjectStringMapBuilder` in the `KafkaInboundGatewaySpec.getComponentsToRegister()`

* Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

* * Remove trailing whitespace in the `ScriptMessageSourceSpec`

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant