Re: [PR] Add check to prevent redundant values in headers when using GZIPOutInterceptor [cxf]
yvrng commented on code in PR #1819: URL: https://github.com/apache/cxf/pull/1819#discussion_r1573205491 ## core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java: ## @@ -337,7 +337,10 @@ private static void addHeader(Message message, String name, String value) { if (header.isEmpty()) { header.add(value); } else { -header.set(0, header.get(0) + "," + value); +String existingValue = header.get(0); +if (!existingValue.contains(value)) { Review Comment: I was thinking the same, and I confirm, I get the same result by adding the item directly to the list: values are concatenated with a comma. -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Add check to prevent redundant values in headers when using GZIPOutInterceptor [cxf]
reta commented on code in PR #1819: URL: https://github.com/apache/cxf/pull/1819#discussion_r1573288108 ## core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java: ## @@ -323,21 +323,14 @@ public void thresholdReached() throws IOException { * @param value the value to add */ private static void addHeader(Message message, String name, String value) { -Map> protocolHeaders = CastUtils.cast((Map)message -.get(Message.PROTOCOL_HEADERS)); -if (protocolHeaders == null) { -protocolHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); -message.put(Message.PROTOCOL_HEADERS, protocolHeaders); +Map> 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 header = CastUtils.cast((List)protocolHeaders.get(name)); -if (header == null) { -header = new ArrayList<>(); -protocolHeaders.put(name, header); -} -if (header.isEmpty()) { +List header = headers.computeIfAbsent(name, k -> new ArrayList<>()); +if (header.isEmpty() || !header.contains(value)) { Review Comment: @yvrng I think we are missing protocol headers update here: ``` protocolHeaders.put(name, header); ``` -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Add check to prevent redundant values in headers when using GZIPOutInterceptor [cxf]
reta commented on code in PR #1819: URL: https://github.com/apache/cxf/pull/1819#discussion_r1573288108 ## core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java: ## @@ -323,21 +323,14 @@ public void thresholdReached() throws IOException { * @param value the value to add */ private static void addHeader(Message message, String name, String value) { -Map> protocolHeaders = CastUtils.cast((Map)message -.get(Message.PROTOCOL_HEADERS)); -if (protocolHeaders == null) { -protocolHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); -message.put(Message.PROTOCOL_HEADERS, protocolHeaders); +Map> 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 header = CastUtils.cast((List)protocolHeaders.get(name)); -if (header == null) { -header = new ArrayList<>(); -protocolHeaders.put(name, header); -} -if (header.isEmpty()) { +List header = headers.computeIfAbsent(name, k -> new ArrayList<>()); +if (header.isEmpty() || !header.contains(value)) { Review Comment: ~@yvrng I think we are missing protocol headers update here:~ ``` protocolHeaders.put(name, header); ``` My bad, the `protocolHeaders` -> `headers`, missed that ## core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java: ## @@ -323,21 +323,14 @@ public void thresholdReached() throws IOException { * @param value the value to add */ private static void addHeader(Message message, String name, String value) { -Map> protocolHeaders = CastUtils.cast((Map)message -.get(Message.PROTOCOL_HEADERS)); -if (protocolHeaders == null) { -protocolHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); -message.put(Message.PROTOCOL_HEADERS, protocolHeaders); +Map> 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 header = CastUtils.cast((List)protocolHeaders.get(name)); -if (header == null) { -header = new ArrayList<>(); -protocolHeaders.put(name, header); -} -if (header.isEmpty()) { +List header = headers.computeIfAbsent(name, k -> new ArrayList<>()); +if (header.isEmpty() || !header.contains(value)) { Review Comment: ~@yvrng I think we are missing protocol headers update here:~ ``` protocolHeaders.put(name, header); ``` ## core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java: ## @@ -323,21 +323,14 @@ public void thresholdReached() throws IOException { * @param value the value to add */ private static void addHeader(Message message, String name, String value) { -Map> protocolHeaders = CastUtils.cast((Map)message -.get(Message.PROTOCOL_HEADERS)); -if (protocolHeaders == null) { -protocolHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); -message.put(Message.PROTOCOL_HEADERS, protocolHeaders); +Map> 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 header = CastUtils.cast((List)protocolHeaders.get(name)); -if (header == null) { -header = new ArrayList<>(); -protocolHeaders.put(name, header); -} -if (header.isEmpty()) { +List header = headers.computeIfAbsent(name, k -> new ArrayList<>()); +if (header.isEmpty() || !header.contains(value)) { Review Comment: My bad, the `protocolHeaders` -> `headers`, missed that -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Exception for getUserPrincipal() in AbstractHTTPDestination is slurped since CXF 4.1.x [cxf]
rzo1 commented on code in PR #1822: URL: https://github.com/apache/cxf/pull/1822#discussion_r1573294891 ## rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java: ## @@ -410,8 +410,12 @@ private boolean isWSAddressingReplyToSpecified(Exchange ex) { public Principal getUserPrincipal() { try { return req.getUserPrincipal(); -} catch (Exception ex) { -return null; +} catch (Exception e) { Review Comment: Hi @ffang , TomEE is happy with your fix. CI is green again ;-) Thx for it ! Gruß Richard -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Add check to prevent redundant values in headers when using GZIPOutInterceptor [cxf]
reta merged PR #1819: URL: https://github.com/apache/cxf/pull/1819 -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] Add check to prevent redundant values in headers when using GZIPOutInterceptor [cxf]
reta commented on PR #1819: URL: https://github.com/apache/cxf/pull/1819#issuecomment-2067714968 Thanks @yvrng ! -- 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: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org