You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2021/03/22 18:32:53 UTC

[GitHub] [cxf] alanmehio commented on a change in pull request #762: very minor SonarLint

alanmehio commented on a change in pull request #762:
URL: https://github.com/apache/cxf/pull/762#discussion_r598977631



##########
File path: core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
##########
@@ -456,11 +455,8 @@ private void addHeaderLine(Map<String, List<String>> heads, StringBuilder line)
             }
             value = line.substring(separator);
         }
-        List<String> v = heads.get(name);
-        if (v == null) {
-            v = new ArrayList<>(1);
-            heads.put(name, v);
-        }
+        List<String> v = heads.computeIfAbsent(name, k -> new ArrayList<>(1));
+        heads.put(name, v);

Review comment:
       @amarkevich  .  many thanks for the feedback. I actually missed the javadoc for Map#computeIfAbsent  
   which states:
    The mostcommon usage is to construct a new object serving as an initialmapped value or memoized result, as in: 
    map.computeIfAbsent(key, k -> new Value(f(k)));
   
   additional put has been removed now. with thanks 




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org