Skip to content

Commit fe863b9

Browse files
Add missing check on voltage level existence, when applying the bus modifications in a voltage init modification (#142)
Signed-off-by: Franck LECUYER <[email protected]>
1 parent a34a247 commit fe863b9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/org/gridsuite/modification/modifications/VoltageInitModification.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ private void applyBusModification(Network network, ReportNode subReportNode) {
8181
List<ReportNode> reports = new ArrayList<>();
8282
for (VoltageInitBusModificationInfos m : voltageInitModificationInfos.getBuses()) {
8383
String voltageLevelId = m.getVoltageLevelId();
84-
Bus bus;
84+
Bus bus = null;
8585
if (voltageLevelId != null) {
8686
final VoltageLevel voltageLevel = network.getVoltageLevel(voltageLevelId);
87-
bus = voltageLevel.getBusView().getBus(m.getBusId());
87+
if (voltageLevel != null) {
88+
bus = voltageLevel.getBusView().getBus(m.getBusId());
89+
}
8890
} else {
8991
bus = network.getBusView().getBus(m.getBusId());
9092
}

src/test/java/org/gridsuite/modification/modifications/VoltageInitModificationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ protected ModificationInfos buildModification() {
201201
.busId("v1_0")
202202
.v(230.)
203203
.angle(0.5)
204+
.build(),
205+
VoltageInitBusModificationInfos.builder()
206+
.voltageLevelId("vlNotFound")
207+
.busId("v1_0")
208+
.v(230.)
209+
.angle(0.5)
204210
.build()))
205211
.rootNetworkName("rootNetwork1")
206212
.nodeName("node1")

0 commit comments

Comments
 (0)