armeria
armeria copied to clipboard
Fix a bug where CORS headers are not injected when a `ServerErrorHandler` is set
Motivation:
ServerErrorHandler.renderStatus() is used in DefaultServerErrorHandler and may not be called in a custom ServerErrorHandler. Attempting to inject CORS headers via CorsServerErrorHandler.renderStatus() may not work.
Modifications:
- Use
ctx.mutateAdditionalResponseHeaders()to set CORS headers instead of mutating the response headers. - Store whether a CORS is set by
CorsServiceto ctx.attr().- The value is used in
CorsServerErrorHandlerto set if missing
- The value is used in
Result:
- CORS headers for failed requests are now correctly set even when a custom
ServerErrorHandleris configured. - Fixes #5493
🔍 Build Scan® (commit: 806540290b692a57c44451e4502668d49120b07d)
| Job name | Status | Build Scan® |
|---|---|---|
| build-ubicloud-standard-8-jdk-8 | ✅ | https://ge.armeria.dev/s/fazkthe3ihwae |
| build-ubicloud-standard-8-jdk-21-snapshot-blockhound | ✅ | https://ge.armeria.dev/s/67szeu7b6bgwk |
| build-ubicloud-standard-8-jdk-17-min-java-17-coverage | ✅ | https://ge.armeria.dev/s/byss46mekt4qg |
| build-ubicloud-standard-8-jdk-17-min-java-11 | ✅ | https://ge.armeria.dev/s/yc5gh2v74f4lw |
| build-ubicloud-standard-8-jdk-17-leak | ✅ | https://ge.armeria.dev/s/ulwpjvcbybspa |
| build-ubicloud-standard-8-jdk-11 | ✅ | https://ge.armeria.dev/s/6d4wvjvp2njtm |
| build-macos-12-jdk-21 | ✅ | https://ge.armeria.dev/s/dwxkaqdngnqqg |