Skip to content

Remove TransactionManager's static ThreadLocal context mapping - #772

Merged
ar merged 1 commit into
mainfrom
fix/issue-770-tm-threadlocal
Sep 4, 2026
Merged

ar merged 1 commit into
mainfrom
fix/issue-770-tm-threadlocal

Conversation

@ar

@ar ar commented Sep 4, 2026

Copy link
Copy Markdown
Member

Implements #770.

What

Removes from TransactionManager:

  • the two static ThreadLocal fields holding the current transaction's context and id,
  • the setThreadLocal / removeThreadLocal helpers and their call sites around the participant run,
  • the public static accessors getSerializable(), getContext() and getId().

Why

With virtual threads and a large session count, per-thread state set and cleared on every transaction is a leak vector and ambient state the taxonomy work deliberately avoids: the trace id travels in the Context (#769), not in a thread-local. Every participant already receives the id and the context as parameters.

Impact

No caller of the three accessors exists in jPOS main or test sources, the docbook, jPOS-EE, or the Control Plane. They were public API, so:

Release note. TransactionManager.getSerializable(), getContext() and getId() are removed. Code that used them to reach the current context from a helper invoked inside a participant must receive the context as a parameter instead.

Tests

No test change needed. Full :jpos:test and :jpos:javadoc pass.

The TM set two static ThreadLocals around each transaction's
participant run and exposed them through the static accessors
getSerializable(), getContext() and getId(). With virtual threads and a
large session count that per-thread state is a leak vector, and the
context already reaches every participant as a parameter. No caller
exists in jPOS, jPOS-EE or the Control Plane.

Closes #770
@ar
ar merged commit 9c36b9f into main Sep 4, 2026
1 check passed
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