codeconsole opened a new pull request, #3105: URL: https://github.com/apache/groovy/pull/3105
`BroadcastChannel.asPublisher()` now ends a subscriber that arrives after the broadcast closed the same way as one that was attached before the close. After `close()` it receives `onComplete`, so `for await (x in broadcast.asPublisher())` ends without values and `await broadcast.asPublisher()` returns `null`. Before, both threw `ChannelClosedException`. After `close(failure)` it receives `failure` itself, not a `ChannelClosedException` wrapping it. This matches `SubmissionPublisher`, `Agent.changes()` and `for await` over a closed `AsyncChannel`, and makes the result independent of whether the consumer subscribed before or after the producer closed. `BroadcastChannel.subscribe()` still throws `ChannelClosedException` once the broadcast is closed. The async channels guide says so. `BroadcastChannel` shipped in 6.0.0, so this changes behavior there; it is a candidate for master only. ## Tests `BroadcastChannelAsPublisherTest` (marked `// GROOVY-12571`): a subscriber and a `for await` that arrive after `close()` and after `close(failure)`; they fail without the change. The `groovy.concurrent` tests pass (271), as do the Checkstyle and CodeNarc gates. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
