Skip to content

make setter fields volatile for concurrent decoder modification#766

Merged
iparadiso merged 1 commit into
2.xfrom
fix/AbstractConfigVolatility
Jun 2, 2026
Merged

make setter fields volatile for concurrent decoder modification#766
iparadiso merged 1 commit into
2.xfrom
fix/AbstractConfigVolatility

Conversation

@iparadiso

Copy link
Copy Markdown
Contributor

Summary

  • decoder and interpolator in AbstractConfig can be updated at runtime via setDecoder() / setStrInterpolator(). Without volatile, the JVM is not required to flush a write on one thread to main memory, so other threads may observe stale values indefinitely.
  • Marking both fields volatile establishes the necessary happens-before relationship: any write is immediately visible to all subsequent reads across threads.
  • volatile is the right level of synchronization here — both setters are simple unconditional single-field assignments with no compound read-modify-write, so no additional atomicity guarantee is needed.

@iparadiso iparadiso merged commit f40de16 into 2.x Jun 2, 2026
5 checks 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.

2 participants