Skip to content

Fix isCommitted() check in response header filters#4115

Open
chenws1012 wants to merge 1 commit intospring-cloud:mainfrom
chenws1012:fix/response-header-iscommitted-check
Open

Fix isCommitted() check in response header filters#4115
chenws1012 wants to merge 1 commit intospring-cloud:mainfrom
chenws1012:fix/response-header-iscommitted-check

Conversation

@chenws1012
Copy link
Copy Markdown

@chenws1012 chenws1012 commented Mar 25, 2026

What changes were proposed in this pull request?

Add isCommitted() check to response header filters to prevent
UnsupportedOperationException when response is already committed
by filters like RequestRateLimiter.

Fix versions affected

  • 4.0.x
  • 4.1.x
  • 4.2.x
  • 5.0.x

What is the issue related to this PR?

Fixes #3718

How was this patch tested?

Existing tests pass. The issue occurs when:

  1. RequestRateLimiter rejects a request (response committed)
  2. Post-processing response header filters try to modify headers

With this fix, filters check isCommitted() before modification.

Checklist

  • Code compiled successfully
  • Tests pass (./mvnw test)
  • Added documentation (if needed)
  • Commit message follows conventions

Add isCommitted() check to prevent UnsupportedOperationException
when modifying response headers after request is rejected by
filters like RequestRateLimiter.

Affected filters:
- SetResponseHeaderGatewayFilterFactory
- DedupeResponseHeaderGatewayFilterFactory
- SecureHeadersGatewayFilterFactory
- RewriteResponseHeaderGatewayFilterFactory
- RewriteLocationResponseHeaderGatewayFilterFactory

Fixes spring-cloudgh-3718

Signed-off-by: chenwenshun <chenwenshun@gmail.com>
@chenws1012 chenws1012 force-pushed the fix/response-header-iscommitted-check branch 2 times, most recently from f0e9f45 to 41a238a Compare March 25, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception with RequestRateLimiter filter combined with response header filters

2 participants