Skip to content

Commit 1a7f24d

Browse files
review (bis)
1 parent 8301e9d commit 1a7f24d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/gridsuite/voltageinit/server/service/VoltageInitWorkerService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,19 @@ private Pair<Network, OpenReacResult> run(VoltageInitRunContext context, UUID re
118118
Network network = voltageInitObserver.observe("network.load", () ->
119119
getNetwork(context.getNetworkUuid(), context.getVariantId()));
120120

121+
AtomicReference<Reporter> rootReporter = new AtomicReference<>(Reporter.NO_OP);
121122
if (context.getReportUuid() != null) {
122123
String rootReporterId = context.getReporterId() == null ? VOLTAGE_INIT_TYPE_REPORT : context.getReporterId() + "@" + context.getReportType();
123-
Reporter rootReporter = new ReporterModel(rootReporterId, rootReporterId);
124-
context.setRootReporter(rootReporter.createSubReporter(context.getReportType(), VOLTAGE_INIT_TYPE_REPORT, VOLTAGE_INIT_TYPE_REPORT, context.getReportUuid().toString()));
124+
rootReporter.set(new ReporterModel(rootReporterId, rootReporterId));
125+
context.setRootReporter(rootReporter.get().createSubReporter(context.getReportType(), VOLTAGE_INIT_TYPE_REPORT, VOLTAGE_INIT_TYPE_REPORT, context.getReportUuid().toString()));
125126
// Delete any previous VoltageInit computation logs
126127
voltageInitObserver.observe("report.delete", () ->
127128
reportService.deleteReport(context.getReportUuid(), context.getReportType()));
128129
}
129130
CompletableFuture<OpenReacResult> future = runVoltageInitAsync(context, network, resultUuid);
130131
if (context.getReportUuid() != null) {
131132
voltageInitObserver.observe("report.send", () ->
132-
reportService.sendReport(context.getReportUuid(), context.getRootReporter()));
133+
reportService.sendReport(context.getReportUuid(), rootReporter.get()));
133134
}
134135

135136
return future == null ? Pair.of(network, null) : Pair.of(network, voltageInitObserver.observeRun("run", future::get));

0 commit comments

Comments
 (0)