Skip to content

INT-3333: Return empty list as is from DB gateway #3907

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

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

artembilan
Copy link
Member

Fixes https://jira.spring.io/browse/INT-3333

In JdbcOutboundGateway and JpaOutboundGateway the empty result list is treated as "no reply" and therefore null is returned cause the flow to stop at this point.
It is better to return such a result as is and the target application to decided what to do with it, e.g. a discardChannel on a downstream splitter configuration.

NOTE: the MongoDbOutboundGateway doesn't treat an empty result as a null

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

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

Just doc polishing.

Comment on lines +368 to +370
Starting with the version 6.0, the `JdbcOutboundGateway` returns an empty list result as is instead of converting it to `null` as it was before with the meaning "no reply".
This caused an extra configuration in applications where handling of empty lists is a part of downstream logic.
See <<./splitter.adoc#split-stream-and-flux,Splitter Discard Channel>> for possible empty list handling option.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Starting with the version 6.0, the `JdbcOutboundGateway` returns an empty list result as is instead of converting it to `null` as it was before with the meaning "no reply".
This caused an extra configuration in applications where handling of empty lists is a part of downstream logic.
See <<./splitter.adoc#split-stream-and-flux,Splitter Discard Channel>> for possible empty list handling option.
Starting with the version 6.0, the `JdbcOutboundGateway` returns an empty list result when there are no records returned by the query.
Previously, `null` was returned, ending the flow, or throwing an exception, depending on `requiresReply`.
This required extra configuration in applications where handling of empty lists is part of the downstream logic.
See <<./splitter.adoc#split-stream-and-flux,Splitter Discard Channel>> for possible empty list handling options.
Or, to revert to the previous behavior, add a `filter` after the gateway to filter out empty lists.

artembilan and others added 2 commits October 11, 2022 12:11
Fixes https://jira.spring.io/browse/INT-3333

In `JdbcOutboundGateway` and `JpaOutboundGateway` the empty result list
is treated as "no reply" and therefore `null` is returned cause
the flow to stop at this point.
It is better to return such a result as is and the target application to
decided what to do with it, e.g. a `discardChannel` on a downstream splitter
configuration.

NOTE: the `MongoDbOutboundGateway` doesn't treat an empty result as a `null`
Co-authored-by: Gary Russell <[email protected]>
@garyrussell garyrussell merged commit f7dd876 into spring-projects:main Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants