Skip to content

fix: extract request-scoped values before virtual thread in emitAuditEvent#194

Open
Harishrs2006 wants to merge 1 commit into
reshaprio:mainfrom
Harishrs2006:fix/186-audit-async-context-leak
Open

fix: extract request-scoped values before virtual thread in emitAuditEvent#194
Harishrs2006 wants to merge 1 commit into
reshaprio:mainfrom
Harishrs2006:fix/186-audit-async-context-leak

Conversation

@Harishrs2006

Copy link
Copy Markdown

Fixes #186

Fix: move all request.* and serverRequest.* accesses to before the
Thread.startVirtualThread() call,
where the Vert.x context is still live

…Event

Fixes reshaprio#186

Variables captured inside Thread.startVirtualThread were read from the
Vert.x HttpServerRequest after the HTTP response completed. Vert.x
recycles the connection context at that point, so remoteAddress() and
getHeader() on the virtual thread could throw IllegalStateException or
return stale data, silently dropping audit logs.

Fix: move all request.* and serverRequest.* accesses to before the
Thread.startVirtualThread() call. durationMs and traceId were already
correctly captured in this scope.

Signed-off-by: Harish R S <harishrs21082006@gmail.com>
@Harishrs2006 Harishrs2006 requested a review from lbroudoux as a code owner June 13, 2026 19:39
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.

Bug (code Quality): Async context leak in McpController.java audit logging

1 participant