Skip to content

Thread Safety: Synchronize MockNcursesBridge.setTerminalSize() #255

Description

@sfloess

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

Scope

Address issue #5 from the parent issue:

MockNcursesBridge.setTerminalSize() not synchronized (MockNcursesBridge.java lines 129-159)

  • Does not synchronize access to width/height/screen fields
  • Concurrent calls to getTerminalWidth()/getTerminalHeight() could read torn/inconsistent values
  • Concurrent resize could cause ArrayIndexOutOfBoundsException if screen buffer is swapped mid-operation

Proposed Fix

Add synchronized modifier to setTerminalSize() and coordinate with getTerminalWidth(), getTerminalHeight(), and screen buffer access methods.

Acceptance Criteria

  • setTerminalSize() is synchronized
  • Width/height/screen reads are consistent with writes
  • No torn reads during concurrent resize
  • 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