diff --git a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java index 333a49736..2b38ded45 100644 --- a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java +++ b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java @@ -316,7 +316,7 @@ public ImmutableMap readAttributes(File file, String attributes) throw new IllegalArgumentException("invalid attributes: " + attributes); } - Map result = new HashMap<>(); + ImmutableMap.Builder result = ImmutableMap.builder(); if (attrs.size() == 1 && attrs.contains(ALL_ATTRIBUTES)) { // for 'view:*' format, get all keys for all providers for the view AttributeProvider provider = providersByName.get(view); @@ -333,7 +333,7 @@ public ImmutableMap readAttributes(File file, String attributes) } } - return ImmutableMap.copyOf(result); + return result.buildKeepingLast(); } /** @@ -351,7 +351,8 @@ public A readAttributes(File file, Class type throw new UnsupportedOperationException("unsupported attributes type: " + type); } - private static void readAll(File file, AttributeProvider provider, Map map) { + private static void readAll( + File file, AttributeProvider provider, ImmutableMap.Builder map) { for (String attribute : provider.attributes(file)) { Object value = provider.get(file, attribute);