Skip to content

Commit

Permalink
fix: deadlock in the ldes client connector (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobulcke authored Oct 21, 2024
1 parent f3fe359 commit be6d122
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@
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) {
tokenService.updateToken(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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be6d122

Please sign in to comment.