Repository navigation
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Reviewed 879300f.
The three local controllers and their dispatch filter now share the same explicit enablement condition. With the feature absent or false, a broad health prefix cannot reach a local writer because no handler is registered. Explicit enablement retains the existing localKey check before health dispatch, and file mode continues to reject conflicting writers. The omitted-property compatibility change is documented. This is a startup-registration change and adds no work to ordinary forwarding.
Targeted validation includes real Boot/HTTP dispatch: disabled file-mode writes return 404 without mutating the cache; enabled local management rejects a missing key and accepts the configured key.
Targeted test report: 37 cases, 0 failures, 0 errors, 0 skipped. Checkstyle, separately executed Apache RAT and git diff --check pass. Validation used ./mvnw and Corretto 21/project target 17; no full-repository/Docker E2E pass is claimed. Required CI must pass before merge.
Fixes #8221.
Problem
With
shenyu.local.enabled=falseonly the local dispatch filter is removed; theLocal*Controllerhandlers stay registered as ordinary/shenyucontrollers.HealthFilterdispatches configured path prefixes directly toDispatcherHandlerwithout a method restriction, so broadeningshenyu.health.pathsto/exposes anonymous local plugin/selector/rule/metadata/app-auth writes. The starter's filter condition also usedmatchIfMissing=true, contradicting thefalsedefault ofShenyuConfig.Local.Change
LocalDispatcherFilternow share one explicit gate:shenyu.local.enabled=true(matchIfMissing=false).false, both the controllers and the filter are absent, so even a health prefix matching/finds no/shenyuhandler and cannot reach a writer. Withtrue, the existing key filter still runs before health dispatch and rejects missing/wrong keys.HealthFilterbehavior and ordinary forwarding are unchanged.shenyu.local.enabled=trueand configuresha512Key; documented in the file-mode README, bootstrap defaults and root README. File mode continues to force it off.Tests
ShenyuConfigurationTestasserts the filter and all three controllers are absent when the property is omitted orfalse, and present whentrue.FileModeIntegrationTeststarts a real Boot application withshenyu.health.paths=/and asserts a POST to/shenyu/plugin/rule/saveOrUpdatereturns 404 and leaves the rule cache unchanged; the controller and filter beans are absent.LocalManagementDispatchTestboots a real HTTP server with explicit enablement and a broad health prefix: a missinglocalKeyis rejected with 403, while the correct key reaches the controller and updates the cache.Verification
Checkstyle clean on the touched modules. No request hot-path change: only startup bean registration is gated.