From 1a7f24de627cff17ab976c6c49759e021bda4e40 Mon Sep 17 00:00:00 2001 From: Tristan Chuine Date: Tue, 9 Apr 2024 16:52:33 +0200 Subject: [PATCH] review (bis) --- .../server/service/VoltageInitWorkerService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gridsuite/voltageinit/server/service/VoltageInitWorkerService.java b/src/main/java/org/gridsuite/voltageinit/server/service/VoltageInitWorkerService.java index 7d6ffb4..129c9ed 100644 --- a/src/main/java/org/gridsuite/voltageinit/server/service/VoltageInitWorkerService.java +++ b/src/main/java/org/gridsuite/voltageinit/server/service/VoltageInitWorkerService.java @@ -118,10 +118,11 @@ private Pair run(VoltageInitRunContext context, UUID re Network network = voltageInitObserver.observe("network.load", () -> getNetwork(context.getNetworkUuid(), context.getVariantId())); + AtomicReference rootReporter = new AtomicReference<>(Reporter.NO_OP); if (context.getReportUuid() != null) { String rootReporterId = context.getReporterId() == null ? VOLTAGE_INIT_TYPE_REPORT : context.getReporterId() + "@" + context.getReportType(); - Reporter rootReporter = new ReporterModel(rootReporterId, rootReporterId); - context.setRootReporter(rootReporter.createSubReporter(context.getReportType(), VOLTAGE_INIT_TYPE_REPORT, VOLTAGE_INIT_TYPE_REPORT, context.getReportUuid().toString())); + rootReporter.set(new ReporterModel(rootReporterId, rootReporterId)); + context.setRootReporter(rootReporter.get().createSubReporter(context.getReportType(), VOLTAGE_INIT_TYPE_REPORT, VOLTAGE_INIT_TYPE_REPORT, context.getReportUuid().toString())); // Delete any previous VoltageInit computation logs voltageInitObserver.observe("report.delete", () -> reportService.deleteReport(context.getReportUuid(), context.getReportType())); @@ -129,7 +130,7 @@ private Pair run(VoltageInitRunContext context, UUID re CompletableFuture future = runVoltageInitAsync(context, network, resultUuid); if (context.getReportUuid() != null) { voltageInitObserver.observe("report.send", () -> - reportService.sendReport(context.getReportUuid(), context.getRootReporter())); + reportService.sendReport(context.getReportUuid(), rootReporter.get())); } return future == null ? Pair.of(network, null) : Pair.of(network, voltageInitObserver.observeRun("run", future::get));