Skip to content

StreamPollFeeder.exception should be volatile #386

Description

@elharo

StreamPollFeeder.exception (line 38) is not declared volatile, but is written by the run() thread (line 79) and read from other threads via getException() (line 101). While waitUntilDone() calls join() which establishes a happens-before for reads that happen after the thread terminates, if getException() is called concurrently from another thread before waitUntilDone(), the read may see stale null.

StreamPumper already uses volatile for its exception field (line 41). StreamPollFeeder should follow the same pattern for consistency and correctness.

Fix: declare exception as volatile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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