NPE when returning null as a tenantId in TenantIdProvider

Hey there,

I implemented a custom TenantIdProvider as an engine plugin following this example. Only one difference: I return null as a tenant ID when there is either no authentication or the authenticated user is not associated with a tenant.

Which should be OK, because the javadoc for TenantIdProvider says: Implementors can either return a tenant id or null. If null is returned the case instance is not assigned a tenant id.

It seems to be working for normal (BPMN) process instances, however, I get a NPE when I try to start a new case without authentication.

Could it be that there is a null check missing in the CaseExecutionEntity?

I appreciate your help!

Ben

Hi Ben,

can you please provide a failing test for this. In the engine, we have a test which should verify the behavior. So it would help to find the difference.

Best regards,
Philipp

I found it,

actually it was kind of my mistake.

I missed out that an authenticated user with no association to a tenant causes

currentAuthentication.getTenantIds();

to be null instead of returning an empty list like the example suggests.

Best Regards,

Ben

1 Like