Skip to content

Thread Safety: Make Container.modificationCount volatile or atomic #253

Description

@sfloess

Part of #224: Improve Thread Safety in Component and Container

Scope

Address issue #3 from the parent issue:

Container.modificationCount not volatile (Container.java line 23)

  • modificationCount field is NOT volatile
  • Mutations in one thread may not be visible to other threads reading it in detectExternalMutation() (line 106)
  • Stale snapshot reuse means cache invalidation might not trigger, causing rendering bugs

Proposed Fix

Make modificationCount volatile or replace with AtomicInteger.

Acceptance Criteria

  • modificationCount has proper memory visibility guarantees
  • detectExternalMutation() always sees latest value
  • Existing tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions