[
https://issues.apache.org/jira/browse/WW-5602?focusedWorklogId=998596&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-998596
]
ASF GitHub Bot logged work on WW-5602:
--------------------------------------
Author: ASF GitHub Bot
Created on: 04/Jan/26 16:04
Start Date: 04/Jan/26 16:04
Worklog Time Spent: 10m
Work Description: 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)
Issue Time Tracking
-------------------
Worklog Id: (was: 998596)
Remaining Estimate: 0h
Time Spent: 10m
> Can't specify empty charset on StreamResult
> -------------------------------------------
>
> Key: WW-5602
> URL: https://issues.apache.org/jira/browse/WW-5602
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter
> Affects Versions: 6.8.0
> Reporter: Andrea Vettori
> Priority: Minor
> Fix For: 6.9.0, 7.2.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> When serving binary files using StreamResult the Content Type header should
> NOT contain a charset specification.
> If the charset is not specified in the StreamResult, UTF-8 is automatically
> applied.
> If the charset is specified with an expression, and the expression evaluates
> to null/empty string, an invalid
> ;charset=
> specification is added to the content-type header on the StreamResult.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)