The GitHub Actions job "Headers" on 
pekko.git/fix/streamref-double-materialization has succeeded.
Run started by GitHub user He-Pin (triggered by He-Pin).

Head commit for run:
6aa77d6fdbeb78f3ac3a6ad8c369e8f3e4988a5c / 虎鸣 <[email protected]>
fix(stream): prevent double materialization of SourceRef and SinkRef with clear 
error

Motivation:
SourceRefImpl.source and SinkRefImpl.sink() create a new stage instance on
every access. If a user accidentally materializes the returned Source/Sink
more than once, multiple stage instances compete for the same partner
handshake, causing the second materialization to fail with a confusing
error message.

Modification:
Add an AtomicBoolean guard per SourceRef/SinkRef instance. When the
backing stage is materialized, the guard is atomically claimed via
compareAndSet. A second materialization attempt throws a clear
IllegalStateException explaining that SourceRef/SinkRef is single-use,
instead of the previous opaque handshake failure.

Result:
Double materialization of SourceRef or SinkRef now fails fast with a
descriptive error: "This SourceRef/SinkRef has already been materialized.
SourceRef/SinkRef is single-use: calling .source/.sink() and materializing
it more than once is not supported." Concurrent materialization attempts
are also correctly rejected (exactly one succeeds, all others fail).

Tests:
- stream-tests/testOnly org.apache.pekko.stream.scaladsl.StreamRefsSpec:
  27/27 passed, including sequential and concurrent (10-thread latch)
  double-materialization tests for both SourceRef and SinkRef

References:
Fixes #3106

Report URL: https://github.com/apache/pekko/actions/runs/27874326059

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to