From be6d1225ffc8d1594b3fba6491a56471a51ca8ab Mon Sep 17 00:00:00 2001 From: Jonas Bulcke <127748878+jobulcke@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:30:32 +0200 Subject: [PATCH] fix: deadlock in the ldes client connector (#702) --- .../ldes/ldio/LdioLdesClientConnectorApi.java | 11 ++--------- .../config/LdioLdesClientConnectorAutoConfig.java | 3 +-- .../ldes/ldio/LdioLdesClientConnectorTest.java | 3 +-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java index b89c83611..ec5971543 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java @@ -3,17 +3,13 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TransferService; -import static be.vlaanderen.informatievlaanderen.ldes.ldio.pipeline.status.PipelineStatusTrigger.START; - public class LdioLdesClientConnectorApi { private final TransferService transferService; private final TokenService tokenService; - private final LdioLdesClient ldesClient; - public LdioLdesClientConnectorApi(TransferService transferService, TokenService tokenService, LdioLdesClient ldesClient) { + public LdioLdesClientConnectorApi(TransferService transferService, TokenService tokenService) { this.transferService = transferService; this.tokenService = tokenService; - this.ldesClient = ldesClient; } public void handleToken(String token) { @@ -21,10 +17,7 @@ public void handleToken(String token) { } public String handleTransfer(String transfer) { - String response = transferService.startTransfer(transfer).getBodyAsString() - .orElse(""); - ldesClient.updateStatus(START); - return response; + return transferService.startTransfer(transfer).getBodyAsString().orElse(""); } public void shutdown() { diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java index e2cfd6150..c7723b3cb 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java @@ -71,6 +71,7 @@ public LdioInput configure(LdiAdapter adapter, ComponentExecutor executor, Appli urlProxy); final var eventStreamPropertiesFetcher = new EventStreamPropertiesFetcher(edcRequestExecutor); final var clientStatusConsumer = new ClientStatusConsumer(pipelineName, clientStatusService); + eventPublisher.publishEvent(new LdesClientConnectorApiCreatedEvent(pipelineName, new LdioLdesClientConnectorApi(transferService, tokenService))); final MemberSupplier memberSupplier = new MemberSupplierFactory( ldioLdesClientProperties, eventStreamPropertiesFetcher, @@ -82,8 +83,6 @@ public LdioInput configure(LdiAdapter adapter, ComponentExecutor executor, Appli final LdioObserver ldioObserver = LdioObserver.register(NAME, pipelineName, observationRegistry); final var ldesClient = new LdioLdesClient(executor, ldioObserver, memberSupplier, applicationEventPublisher, keepState, clientStatusConsumer); - eventPublisher.publishEvent(new LdesClientConnectorApiCreatedEvent(pipelineName, new LdioLdesClientConnectorApi(transferService, tokenService, ldesClient))); - ldesClient.start(); return ldesClient; } diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorTest.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorTest.java index 34662b7eb..3f4c7337b 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorTest.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorTest.java @@ -39,9 +39,8 @@ class LdioLdesClientConnectorTest { void setup() { transferService = mock(TransferService.class); tokenService = mock(TokenService.class); - final LdioLdesClient ldesClient = mock(LdioLdesClient.class); - eventPublisher.publishEvent(new LdesClientConnectorApiCreatedEvent(endpoint, new LdioLdesClientConnectorApi(transferService, tokenService, ldesClient))); + eventPublisher.publishEvent(new LdesClientConnectorApiCreatedEvent(endpoint, new LdioLdesClientConnectorApi(transferService, tokenService))); } @Test