[
https://issues.apache.org/jira/browse/HADOOP-20006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139276#comment-18139276
]
ASF GitHub Bot commented on HADOOP-20006:
-----------------------------------------
joseluisll opened a new pull request, #8948:
URL: https://github.com/apache/hadoop/pull/8948
### Description of PR
Every server HttpServer2 builds runs QuotingInputFilter, which sets
text/plain; charset=utf-8 before a request reaches its resource, so a JAX-RS
resource that picks its own content type clears that first with
setContentType(null).
That is not enough on Jetty 12, which drops the charset but remembers that
one had been set and appends it to the next content type: WebHDFS would answer
SETPERMISSION with application/octet-stream;charset=null. Clearing the
character encoding as well resets that state.
The idiom moves to JettyUtils#clearContentType, used at all 14 call sites.
TestHttpServer asserts the header a resource that clears and re-sets its
content type sends. No change on Jetty 9.4.
### How was this patch tested?
The changed modules' tests, run by the Yetus precommit and the fork's CI on
this branch.
### For code changes:
- [x] Does the title of this PR start with the corresponding JIRA issue id?
- [ ] Object storage: not applicable, no object store integration touched.
- [ ] If adding new dependencies to the code: not applicable, no new
dependency.
- [ ] If applicable, have you updated the LICENSE files: not applicable.
### AI Tooling
If an AI tool was used:
- [x] The PR includes the phrase "Contains content generated by <tool>"
where <tool> is the name of the AI tool used.
- [x] My use of AI contributions follows the ASF legal policy
https://www.apache.org/legal/generative-tooling.html
Contains content generated by Claude Code.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
> Clear the response charset along with the content type
> ------------------------------------------------------
>
> Key: HADOOP-20006
> URL: https://issues.apache.org/jira/browse/HADOOP-20006
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: common, hdfs, mapreduce, yarn
> Reporter: Jose Luis López
> Priority: Major
>
> Every server {{HttpServer2}} builds runs {{QuotingInputFilter}}, which sets
> {{text/plain; charset=utf-8}} before the request reaches its resource. JAX-RS
> resources that choose their own content type undo it with
> {{response.setContentType(null)}}, at 14 call sites in 13 classes.
> On Jetty 12 that is not enough. The charset is dropped, but the response
> remembers that one was set and appends it to the next content type, so
> WebHDFS SETPERMISSION answers {{application/octet-stream;charset=null}}.
> Types without a default charset are affected, {{application/xml}} among them;
> {{application/json}} is not.
> h3. Changes
> * New {{JettyUtils#clearContentType(HttpServletResponse)}} calls
> {{setContentType(null)}} and {{setCharacterEncoding(null)}}. It uses only
> {{javax.servlet}}.
> * It is used at all 14 call sites: {{NamenodeWebHdfsMethods}}, the WebHDFS
> {{ExceptionHandler}}, {{AMWebServices}}, {{HsWebServices}},
> {{GenericExceptionHandler}}, {{TimelineWebServices}}, {{LogWebService}},
> {{WebServices}}, {{NMWebServices}}, {{RMWebServices}}, {{RouterWebServices}},
> {{TimelineCollectorWebService}} and {{TimelineReaderWebServices}}.
> h3. Compatibility
> No change on Jetty 9.4.
> h3. Tests
> {{TestHttpServer}} asserts the Content-Type header a resource sends after
> clearing and re-setting its content type.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]