Skip to content
Permalink
Browse files
FILEUPLOAD-315 - java8 improvement:
* Use computeIfAbsent
  • Loading branch information
arturobernalg committed Apr 23, 2021
1 parent 289acf5 commit f2fa3c4b49493048dbc7b73fe568e6884550fa60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
@@ -386,12 +386,7 @@ public Map<String, List<FileItem>> parseParameterMap(final RequestContext ctx)

for (final FileItem fileItem : items) {
final String fieldName = fileItem.getFieldName();
List<FileItem> mappedItems = itemsMap.get(fieldName);

if (mappedItems == null) {
mappedItems = new ArrayList<>();
itemsMap.put(fieldName, mappedItems);
}
List<FileItem> mappedItems = itemsMap.computeIfAbsent(fieldName, k -> new ArrayList<>());

mappedItems.add(fileItem);
}
@@ -87,11 +87,7 @@ public Iterator<String> getHeaders(final String name) {
*/
public synchronized void addHeader(final String name, final String value) {
final String nameLower = name.toLowerCase(Locale.ENGLISH);
List<String> headerValueList = headerNameToValueListMap.get(nameLower);
if (null == headerValueList) {
headerValueList = new ArrayList<>();
headerNameToValueListMap.put(nameLower, headerValueList);
}
List<String> headerValueList = headerNameToValueListMap.computeIfAbsent(nameLower, k -> new ArrayList<>());
headerValueList.add(value);
}

0 comments on commit f2fa3c4

Please sign in to comment.