[
https://issues.apache.org/jira/browse/CXF-9099?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Freeman Yue Fang resolved CXF-9099.
-----------------------------------
Fix Version/s: 3.6.6
4.0.7
4.1.1
Resolution: Fixed
> GZIPOutInterceptor : ensure the CXF headers that GZIPOutInterceptor needs to
> resize is modifiable
> -------------------------------------------------------------------------------------------------
>
> Key: CXF-9099
> URL: https://issues.apache.org/jira/browse/CXF-9099
> Project: CXF
> Issue Type: Bug
> Components: Transports
> Reporter: Freeman Yue Fang
> Assignee: Freeman Yue Fang
> Priority: Major
> Fix For: 3.6.6, 4.0.7, 4.1.1
>
>
> In GZIPOutInterceptor some times we need to add new element in CXF headers.
> For example
> {code}
> /**
> * Adds a value to a header. If the given header name is not currently
> * set in the message, an entry is created with the given single value.
> * If the header is already set, the value is appended to the first
> * element of the list, following a comma.
> *
> * @param message the message
> * @param name the header to set
> * @param value the value to add
> */
> private static void addHeader(Message message, String name, String value)
> {
> Map<String, List<String>> headers = CastUtils.cast((Map<?,
> ?>)message.get(Message.PROTOCOL_HEADERS));
> if (headers == null) {
> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
> message.put(Message.PROTOCOL_HEADERS, headers);
> }
> List<String> header = headers.computeIfAbsent(name, k -> new
> ArrayList<>());
> header = new ArrayList<String>(header); //ensure header List is
> modifiable
> if (header.isEmpty() || !header.contains(value)) {
> header.add(value);
> }
> }
> {code}
> But in some cases the header here
> {code}
> List<String> header = headers.computeIfAbsent(name, k -> new
> ArrayList<>());
> {code}
> isn't modifiable. Like if the previous header was created by code
> Arrays.asList(...) which returns a unmodifiable List per java17 doc. In this
> case java.lang.UnsupportedOperationException is thrown
--
This message was sent by Atlassian Jira
(v8.20.10#820010)