Remove forEach() that introduces side-effect inherently
Change-Id: Idd9784d7a8a4064e31b02f65701bc599b2fb3dbf
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
index 44772bf..2716354 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
@@ -80,6 +80,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.DeviceId.deviceId;
@@ -455,9 +456,10 @@
.filter(cp -> !existing.contains(cp))
.collect(Collectors.toSet());
- List<PortDescription> newPorts = Lists.newArrayList();
- ports.forEach(p -> newPorts.add(description(p)));
- missing.forEach(cp -> newPorts.add(description(cp)));
+ List<PortDescription> newPorts = Stream.concat(
+ ports.stream().map(this::description),
+ missing.stream().map(this::description)
+ ).collect(Collectors.toList());
deviceProviderService.updatePorts(device.id(), newPorts);
}