Skip to content

PromiseToCompletableFuture shares two fields across threads without volatile #2281

Done

Description

@lagergren

Narrowed on 2026-11-26: this issue now covers only PromiseToCompletableFuture. The DocumentSymbolData.equals/hashCode part moved to #2285, for 0.31.0. The structure view no longer needs the PsiElement match since #1531, and removing it means deprecating the public LSPDocumentSymbolFeature.matchesPsiElement. #2285 has the evidence; the original text of that part is kept below, struck through.

PromiseToCompletableFuture shares two fields between threads without volatile

PromiseToCompletableFuture.java: cancelled (line 43) and nonBlockingReadActionPromise (line 69) are written and read on different threads (the canceller, and the read action's retries) without volatile or a lock.

The worst case found is one more attempt after a cancel, whose result is thrown away. Make them volatile, or confine them to one thread.

Moved to #2285: DocumentSymbolData.equals breaks the equals/hashCode contract

DocumentSymbolData.java:120-137: equals is true for another DocumentSymbolData with an equal symbol, and also for any PsiElement that matchesPsiElement accepts, while hashCode uses only the symbol. So the relation isn't symmetric, and an object equal to data can have another hash code. The matching was added for the Structure View's Always Select Opened Element (#1381, #1531).

Activity

  1. added this to the 0.30.2 milestone on Nov 26, 2026
  2. lagergren commented on Nov 26, 2026

    @lagergren
    CollaboratorAuthor

    Split in two:

  3. changed the title [-]DocumentSymbolData.equals breaks the equals/hashCode contract, and PromiseToCompletableFuture shares two fields across threads without volatile[/-] [+]PromiseToCompletableFuture shares two fields across threads without volatile[/+] on Nov 26, 2026
  4. added a commit that references this issue on Nov 26, 2026
    9280810
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions