Skip to content

Conversation

artembilan
Copy link
Member

Fixes #8720

Validate MQTT topics for empty strings in the channel adapters configuration

Cherry-pick to 6.1.x & 6.0.x

@artembilan
Copy link
Member Author

I'll back-port to 5.5.x separately: too many breaking changes since then.
Also let me know if this does not cherry-pick properly, so I'll come up with other fix for those versions.

@artembilan artembilan requested a review from tzolov September 8, 2023 20:11
* @since 4.1
*/
@ManagedOperation
public void addTopic(String... topic) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency use the plural naming: topic -> topics.

* @since 4.1
*/
@ManagedOperation
public void addTopics(String[] topic, int[] qos) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, for consistency use the plural naming: topic -> topics.

if (topic == null && this.defaultTopic == null) {
throw new IllegalStateException(
"No topic could be determined from the message and no default topic defined");
if (topic == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the topic be returned as an empty string?

Copy link
Member Author

Choose a reason for hiding this comment

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

The MQTT client validates the topic before publishing.
And that is done in a sync mode, so even if it is returned here as empty, it is going to be reject immediately in that publish() implementations.

Fixes spring-projects#8720

Validate MQTT topics for empty strings in the channel adapters configuration

**Cherry-pick to `6.1.x` & `6.0.x`**
@artembilan artembilan requested a review from tzolov September 12, 2023 16:47
@tzolov tzolov self-assigned this Sep 13, 2023
@tzolov tzolov merged commit f3d0441 into spring-projects:main Sep 13, 2023
@artembilan
Copy link
Member Author

Back-ported to 5.5.x as a82a41e after fixing conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The MQTT protocol doesn't allow an empty topic value nor for publisihng neither for subscribing

2 participants