Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webhook): incorrect deactivation handling #2332

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ public void deregister(RegisteredExecutable.Activated connector) {
LOG.debug(logMessage);
throw new RuntimeException(logMessage);
}
if (registeredConnector != connector) {
var deduplicationId = registeredConnector.context().getDefinition().deduplicationId();
var requesterDeduplicationId = connector.context().getDefinition().deduplicationId();
var registeredDeduplicationId = registeredConnector.context().getDefinition().deduplicationId();

if (!registeredDeduplicationId.equals(requesterDeduplicationId)) {
var logMessage =
"Context: "
+ context
+ " is not registered by the connector with deduplication ID: "
+ deduplicationId
+ requesterDeduplicationId
+ ". Cannot deregister.";
LOG.debug(logMessage);
throw new RuntimeException(logMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import io.camunda.connector.validation.impl.DefaultValidationProvider;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
Expand Down Expand Up @@ -77,12 +76,16 @@ public void webhookMultipleVersionsDisableWebhook() {
var processB1 = buildConnector(webhookDefinition("processB", 1, "myPath2"));

webhook.register(processA1);
webhook.deregister(processA1);

// create a new object to ensure correct instance comparison
var processA1Copy = buildConnector(webhookDefinition("processA", 1, "myPath"));
webhook.deregister(processA1Copy);

webhook.register(processA2);

webhook.register(processB1);
webhook.deregister(processB1);
var processB1Copy = buildConnector(webhookDefinition("processB", 1, "myPath2"));
webhook.deregister(processB1Copy);

var connectorForPath1 = webhook.getWebhookConnectorByContextPath("myPath");

Expand Down Expand Up @@ -163,7 +166,7 @@ public static InboundConnectorContextImpl buildContext(InboundConnectorDetails d
public static InboundConnectorDetails webhookDefinition(
String bpmnProcessId, int version, String path) {
return new InboundConnectorDetails(
UUID.randomUUID().toString(),
bpmnProcessId + version + path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will it be used? If it's user exposed, maybe consider concatenating with dashes or something 🤔 . Just a suggestion.

Suggested change
bpmnProcessId + version + path,
bpmnProcessId + "-" + version + "-" + path,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a mock value for tests only 🙂

List.of(webhookElement(++nextProcessDefinitionKey, bpmnProcessId, version, path)));
}

Expand Down
Loading