Don't create an empty set by using Stream API
Change-Id: I835cbf6f4926c3391e901597b6d8d203f28a3f41
Showing
1 changed file
with
3 additions
and
3 deletions
... | @@ -209,9 +209,9 @@ public class ConsistentLinkResourceStore extends | ... | @@ -209,9 +209,9 @@ public class ConsistentLinkResourceStore extends |
209 | tx.begin(); | 209 | tx.begin(); |
210 | try { | 210 | try { |
211 | Map<ResourceType, Set<ResourceAllocation>> freeResources = getFreeResourcesEx(tx, link); | 211 | Map<ResourceType, Set<ResourceAllocation>> freeResources = getFreeResourcesEx(tx, link); |
212 | - Set<ResourceAllocation> allFree = new HashSet<>(); | 212 | + return freeResources.values().stream() |
213 | - freeResources.values().forEach(allFree::addAll); | 213 | + .flatMap(Collection::stream) |
214 | - return allFree; | 214 | + .collect(Collectors.toSet()); |
215 | } finally { | 215 | } finally { |
216 | tx.abort(); | 216 | tx.abort(); |
217 | } | 217 | } | ... | ... |
-
Please register or login to post a comment