Skip to content

Make TextFileBasedViolationStore thread-safe under parallel test execution#1656

Open
kelunik wants to merge 1 commit into
TNG:mainfrom
kelunik:fix/thread-safe-violation-store
Open

Make TextFileBasedViolationStore thread-safe under parallel test execution#1656
kelunik wants to merge 1 commit into
TNG:mainfrom
kelunik:fix/thread-safe-violation-store

Conversation

@kelunik

@kelunik kelunik commented Jul 6, 2026

Copy link
Copy Markdown

Multiple FreezingArchRule instances each create a fresh TextFileBasedViolationStore and load stored.rules into their own private snapshot. Concurrent saves caused a lost-update: the last writer overwrote the file with only its own entries.

Fix by sharing one FileSyncedProperties per stored.rules canonical path via a static ConcurrentHashMap, and synchronizing writes with a putIfAbsent method that atomically checks, sets, and flushes to disk under one lock.

Fixes #1654.

…ution

Multiple FreezingArchRule instances each create a fresh TextFileBasedViolationStore
and load stored.rules into their own private snapshot. Concurrent saves caused a
lost-update: the last writer overwrote the file with only its own entries.

Fix by sharing one FileSyncedProperties per stored.rules canonical path via a
static ConcurrentHashMap, and synchronizing writes with a putIfAbsent method that
atomically checks, sets, and flushes to disk under one lock.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

TextFileBasedViolationStore is not thread-safe under parallel test execution

1 participant