Repository navigation
fix(auth): clear request state outside jersey (backport 2.0 #36173) - #36222
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved🔴 High risk · The global filter clears cached entities and impersonation context around every request, which could produce incorrect authorization decisions or expose data. Adds VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| public final class PerRequestContextCleanupFilter implements Filter { | ||
|
|
||
| @Override | ||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
There was a problem hiding this comment.
Unchanged parameters lack required markers
The new doFilter parameters never change but lack final. The repository guide requires final on unchanged parameters and local variables. Add it here and to failingChain in the new test. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Backport of #36173 to
2.0.PerRequestContextCleanupFilteron/*to clear that state before and after every request.FreshReadScopechange inBotTokenCache/UserTokenCacheis left out because it builds on Fixes #32052: reject revoked bot tokens and PATs on every pod #32872 and Fixes #34204, #34205: stop event consumers idling after a slow batch, and give fresh reads their own cache #34209, which are not on 2.0. The ADR copy drops that line.PerRequestContextCleanupFilterTest(3) comes along with it.The cleanup looks sound, but the explicit requirement for
finalmarkers must be satisfied before merging.Findings
Summary
Adds
PerRequestContextCleanupFilteraround application requests outside Jersey.Scope acknowledged by Vishnuujain: the
FreshReadScopechanges are intentionally excluded because their prerequisites, #32872 and #34209, are not on2.0.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Application request] --> B[Clear request-local state] B --> C[Run filters and servlet] C --> D[Response or exception] D --> E[Clear request-local state in finally]Reviews (1) · Last reviewed commit: "fix(auth): clear request state outside j..." · Reviewed by Greptile