Skip to content

Propagate authenticated user when send-event task is sent asynchronously#4205

Open
kle-dev wants to merge 1 commit intoflowable:mainfrom
kle-dev:fix/async-send-event-authenticated-user
Open

Propagate authenticated user when send-event task is sent asynchronously#4205
kle-dev wants to merge 1 commit intoflowable:mainfrom
kle-dev:fix/async-send-event-authenticated-user

Conversation

@kle-dev
Copy link
Copy Markdown

@kle-dev kle-dev commented Apr 29, 2026

The async send-event job re-evaluates eventInParameter source expressions in a worker thread, where the Authentication thread-local is not set. As a result expressions like ${authenticatedUserId} resolve to null even though they would resolve correctly when the same task is configured with flowable:sendSynchronously=true.

Capture the authenticated user when the async job is scheduled (storing it on the JobEntity's jobHandlerConfiguration, which the handler does not otherwise use) and restore it in AsyncSendEventJobHandler before invoking the activity behavior. The previous authenticated user is restored in a finally block.

Check List:

  • Unit tests: YES
  • Documentation: NO

The async send-event job re-evaluates eventInParameter source expressions
in a worker thread, where the Authentication thread-local is not set. As a
result expressions like ${authenticatedUserId} resolve to null even though
they would resolve correctly when the same task is configured with
flowable:sendSynchronously=true.

Capture the authenticated user when the async job is scheduled (storing it
on the JobEntity's jobHandlerConfiguration, which the handler does not
otherwise use) and restore it in AsyncSendEventJobHandler before invoking
the activity behavior. The previous authenticated user is restored in a
finally block.
@kle-dev kle-dev force-pushed the fix/async-send-event-authenticated-user branch from 0cc9a18 to 45cbb64 Compare April 29, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant