diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ConfiguredBusImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ConfiguredBusImpl.java index 497b687a8..0fa9f66c6 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ConfiguredBusImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ConfiguredBusImpl.java @@ -14,7 +14,6 @@ import org.apache.commons.collections4.CollectionUtils; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.function.*; import java.util.stream.Collectors; @@ -170,14 +169,10 @@ private void updateCalculatedBusAttributesIfNeeded(double newValue, String volta .getCalculatedBusesForBusView(); if (CollectionUtils.isNotEmpty(calculatedBusAttributesList)) { - List calculatedBusesNum = getAllTerminals().stream().map(t -> { - if (t.getBusView() != null && t.getBusView().getBus() instanceof CalculatedBus) { - CalculatedBus bus = (CalculatedBus) t.getBusView().getBus(); - return bus != null ? bus.getCalculatedBusNum() : null; - } - return null; - }) - .filter(Objects::nonNull).distinct().toList(); + List calculatedBusesNum = getAllTerminals().stream() + .filter(t -> t.isConnected()) + .map(t -> ((CalculatedBus) t.getBusView().getBus()).getCalculatedBusNum()) + .toList(); List busesToUpdateList = IntStream.range(0, calculatedBusAttributesList.size()) .filter(calculatedBusesNum::contains) .mapToObj(calculatedBusAttributesList::get)