lukaszlenart opened a new pull request, #1510:
URL: https://github.com/apache/struts/pull/1510
## Summary
- **Fix WW-5602**: When `contentCharSet` is an expression that evaluates to
null, the content-type header was incorrectly appending `;charset=` with no
value
- **Refactor**: Extract methods and modernize `StreamResult` to improve
extensibility and code quality
## Changes
### Bug Fix (WW-5602)
- Evaluate `contentCharSet` expression before checking for emptiness
- Call `setCharacterEncoding(null)` to clear Dispatcher's default UTF-8
encoding when no charset is specified
- Add test case for expression evaluating to null
### Refactoring
- Add constants: `DEFAULT_BUFFER_SIZE`, `DEFAULT_CONTENT_TYPE`,
`DEFAULT_CONTENT_DISPOSITION`, `DEFAULT_INPUT_NAME`
- Extract `protected` methods for easy extension:
- `resolveInputStream()` - custom stream sources (database, cloud,
generated)
- `applyResponseHeaders()` - custom headers (ETag, X-Custom)
- `applyContentLength()` - custom length calculation
- `streamContent()` - custom buffering, compression, encryption
- Use try-with-resources for cleaner resource management
- Add JavaDoc explaining extensibility of each method
## Test plan
- [x] All 18 `StreamResultTest` tests pass
- [x] New test `testStreamResultWithNullCharSetExpression` verifies the bug
fix
Closes [WW-5602](https://issues.apache.org/jira/browse/WW-5602)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]