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(user-task): prevent npe for non-tenant configurations #68

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -113,11 +113,10 @@ public void openWorkers() {
.jobType("io.camunda.zeebe:userTask")
.handler(userTaskHandler)
.timeout(Integer.MAX_VALUE) // user-tasks are not fetched more than once
.name(workerId)
.tenantId(tenantId);
.name(workerId);
final var workerProperties = camunda8Properties.getUserTaskWorkerProperties(workflowModuleId);
workerProperties.applyToUserTaskWorker(userTaskWorker);
return userTaskWorker;
return tenantId != null ? userTaskWorker.tenantId(tenantId) : userTaskWorker;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change this line into a separate if-statement: Using a tenaer operate is OK in general but not here in combination with the return statement. It tells that different responses are expected depending on the given condition. But actually, the worker needs to be configured properly depending on the given condition regardless whether it is return by the method or not. Additionally, I would place it underneath line 116 since the tenant is an crucial configuration as the other aspects above line 116 but the configuration in 117/118 are nice-to-haves:

        ...
        .name(workerId);

    if (tenantId != null) {
        userTaskWorker.tenantId(tenantId);
    }

    final var workerProperties = ....

})
.forEach(workers::add);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public class Camunda8UserTaskHandler implements JobHandler {
private static final Logger logger = LoggerFactory.getLogger(Camunda8UserTaskHandler.class);

private static final int MAX_ATTEMPTS_OF_ASSIGNING_USERTASKS = 1000;


// default tenant identifier used by camunda 8 if multi-tenancy is disabled
// see https://docs.camunda.io/docs/self-managed/concepts/multi-tenancy/#the-tenant-identifier
private static final String DEFAULT_TENANT_ID = "<default>";

private final Map<String, Camunda8TaskHandler> taskHandlers = new HashMap<>();

private final String workerId;
Expand All @@ -31,8 +35,8 @@ private String internalKey(
final String tenantId,
final String bpmnProcessId,
final String elementId) {

return tenantId + "#" + bpmnProcessId + "#" + elementId;
final var tenantIdKey = DEFAULT_TENANT_ID.equals(tenantId) ? null : tenantId;
return tenantIdKey + "#" + bpmnProcessId + "#" + elementId;

}

Expand Down