Skip to content

ProblemTextFilter cache is not atomic across its two fields #127

Open

Description

@0verEngineer

getFilters() keeps the cache in two separate volatile fields (cachedRawFilterList, cachedFilters) and updates them one after the other. A concurrent caller can therefore get a filter list that was parsed from a different raw string than the one it checked against.

This cannot happen today: the only caller (DocumentMarkupModelScanner) always runs on the EDT. It becomes a real bug as soon as isFiltered is called from another thread, for example a background scan or parallel tests (see #126).

Proposed fix: keep one immutable holder record Cache(String raw, List<Predicate<String>> filters) in a single volatile field and replace it in one write.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions