Skip to content

fix(provider): report null vendor as missing in the provider registry - #2970

Open
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-provider-null-vendor
Open

fix(provider): report null vendor as missing in the provider registry#2970
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-provider-null-vendor

Conversation

@yyqdbngt

@yyqdbngt yyqdbngt commented Sep 2, 2026

Copy link
Copy Markdown

Summary

InstanceProviderRegistry.forVendor and catalogFor looked the vendor up
directly in an EnumMap. EnumMap.get(null) throws NPE, so a null vendor
crashed with a raw NullPointerException instead of the same 501
"No ... provider registered for vendor" that an unregistered vendor already
produces. Both lookups now map a null vendor onto the existing missing-entry
code path.

Why

The registry is the single lookup SPI for vendor-scoped providers; current
call sites normalize a null InstanceVO.vendor to APACHE first, but the SPI
contract ("unknown vendor -> 501") should hold for null too, so a future
caller passing a raw persisted vendor cannot 500 the request with an NPE.

Testing

cd server && mvn -Dtest="InstanceProviderRegistryTest" test

Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
New regression tests forVendorShouldReportNullVendorAsMissingTest and
catalogForShouldReportNullVendorAsMissingTest assert the 501 BusinessException
(message "No ... provider registered for vendor null") instead of an NPE.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Correct guard against EnumMap.get(null) NPE — surfacing a 501 for null vendors is the right behavior. Tests verify both forVendor and catalogFor.


Automated review by github-manager-bot

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.

3 participants