Skip to content

fix: avoid NPE when selector/rule sync data is null (#6890) - #6925

Open
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6890-http-sync-null-npe
Open

fix: avoid NPE when selector/rule sync data is null (#6890)#6925
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6890-http-sync-null-npe

Conversation

@juicewcode

@juicewcode juicewcode commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #6890

summary

  • Restructure refresh() to clear the cache unconditionally first, following the same implementation as PluginDataRefresh, and return early when the data is empty, so a null payload clears the cache instead of crashing. Behavior for empty and non-empty data is unchanged.
  • Add regression tests covering refresh with null data for both refreshers.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

 When the http sync data is null, CollectionUtils.isEmpty(null) is true and the original code called data.forEach (pluginDataSubscriber::unSelectorSubscribe),
  which threw a NullPointerException. The forEach on the empty/null data was dead
  code in the empty-list case and the NPE trigger in the null case.

  Restructure refresh() to clear the cache unconditionally first, following the
  same implementation as PluginDataRefresh, and return early when the data is
  empty, so a null payload clears the cache instead of crashing. Behavior for
  empty and non-empty data is unchanged.

  Add regression tests covering refresh with null data for both refreshers.
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.

[BUG] CONNACK always returns sessionPresent=true, even for first connect and clean-session clients

1 participant