Committed by
Brian O'Connor
Remove forEach() that introduces side-effect inherently
Change-Id: Idd9784d7a8a4064e31b02f65701bc599b2fb3dbf
Showing
1 changed file
with
5 additions
and
3 deletions
... | @@ -80,6 +80,7 @@ import java.util.Set; | ... | @@ -80,6 +80,7 @@ import java.util.Set; |
80 | import java.util.concurrent.CountDownLatch; | 80 | import java.util.concurrent.CountDownLatch; |
81 | import java.util.concurrent.TimeUnit; | 81 | import java.util.concurrent.TimeUnit; |
82 | import java.util.stream.Collectors; | 82 | import java.util.stream.Collectors; |
83 | +import java.util.stream.Stream; | ||
83 | 84 | ||
84 | import static com.google.common.base.Preconditions.checkNotNull; | 85 | import static com.google.common.base.Preconditions.checkNotNull; |
85 | import static org.onosproject.net.DeviceId.deviceId; | 86 | import static org.onosproject.net.DeviceId.deviceId; |
... | @@ -455,9 +456,10 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -455,9 +456,10 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
455 | .filter(cp -> !existing.contains(cp)) | 456 | .filter(cp -> !existing.contains(cp)) |
456 | .collect(Collectors.toSet()); | 457 | .collect(Collectors.toSet()); |
457 | 458 | ||
458 | - List<PortDescription> newPorts = Lists.newArrayList(); | 459 | + List<PortDescription> newPorts = Stream.concat( |
459 | - ports.forEach(p -> newPorts.add(description(p))); | 460 | + ports.stream().map(this::description), |
460 | - missing.forEach(cp -> newPorts.add(description(cp))); | 461 | + missing.stream().map(this::description) |
462 | + ).collect(Collectors.toList()); | ||
461 | deviceProviderService.updatePorts(device.id(), newPorts); | 463 | deviceProviderService.updatePorts(device.id(), newPorts); |
462 | } | 464 | } |
463 | 465 | ... | ... |
-
Please register or login to post a comment