Skip to content

Commit

Permalink
Fix null pointer exception in ConfiguredBusImpl
Browse files Browse the repository at this point in the history
Signed-off-by: TOURI ANIS <[email protected]>
  • Loading branch information
anistouri committed Sep 10, 2024
1 parent c2c5ecc commit 44bd70a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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;
Expand Down Expand Up @@ -169,7 +170,14 @@ private void updateCalculatedBusAttributesIfNeeded(double newValue, String volta
.getCalculatedBusesForBusView();

if (CollectionUtils.isNotEmpty(calculatedBusAttributesList)) {
List<Integer> calculatedBusesNum = getAllTerminals().stream().map(t -> ((CalculatedBus) t.getBusView().getBus()).getCalculatedBusNum()).distinct().toList();
List<Integer> 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<CalculatedBusAttributes> busesToUpdateList = IntStream.range(0, calculatedBusAttributesList.size())
.filter(calculatedBusesNum::contains)
.mapToObj(calculatedBusAttributesList::get)
Expand Down

0 comments on commit 44bd70a

Please sign in to comment.