[ 
https://issues.apache.org/jira/browse/GROOVY-12571?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Scott Murphy Heiberg updated GROOVY-12571:
------------------------------------------
    Description: 
{code:groovy}
import groovy.concurrent.BroadcastChannel
def broadcast = BroadcastChannel.create()
broadcast.close()
for await (x in broadcast.asPublisher()) { println x } // 
ChannelClosedException; expected: ends without values
{code}

A subscriber that arrives after {{close()}} gets 
{{onError(ChannelClosedException)}}, and after {{close(failure)}} it gets the 
wrapper rather than the failure. A subscriber attached a moment before the 
close completes, or receives the failure itself, so the same program finishes 
or fails depending on timing. Expected: as {{SubmissionPublisher}}, 
{{Agent.changes()}} and {{for await}} over a closed {{AsyncChannel}} behave, a 
late subscriber gets {{onComplete}} after {{close()}} and {{onError(failure)}} 
after {{close(failure)}}. {{BroadcastChannel.subscribe()}} still throws once 
closed.

Behaviour change from 6.0.0: code that caught {{ChannelClosedException}} from a 
publisher of a closed broadcast now sees {{onComplete}} after {{close()}}, or 
{{onError}} with the failure itself after {{close(failure)}}. The PR adds a 
COMPATIBILITY.md entry.

PR: https://github.com/apache/groovy/pull/3105

  was:
{code:groovy}
import groovy.concurrent.BroadcastChannel
def broadcast = BroadcastChannel.create()
broadcast.close()
for await (x in broadcast.asPublisher()) { println x } // 
ChannelClosedException; expected: ends without values
{code}

A subscriber that arrives after {{close()}} gets 
{{onError(ChannelClosedException)}}, and after {{close(failure)}} it gets the 
wrapper rather than the failure. A subscriber attached a moment before the 
close completes, or receives the failure itself, so the same program finishes 
or fails depending on timing. Expected: as {{SubmissionPublisher}}, 
{{Agent.changes()}} and {{for await}} over a closed {{AsyncChannel}} behave, a 
late subscriber gets {{onComplete}} after {{close()}} and {{onError(failure)}} 
after {{close(failure)}}. {{BroadcastChannel.subscribe()}} still throws once 
closed.

Behaviour change in 6.0.0 terms: code that caught {{ChannelClosedException}} 
from a publisher of a closed broadcast now sees {{onComplete}} after 
{{close()}}, or {{onError}} with the failure itself after {{close(failure)}}. 
The PR adds a COMPATIBILITY.md entry.

PR: https://github.com/apache/groovy/pull/3105


> BroadcastChannel.asPublisher() fails a subscriber that arrives after the 
> broadcast closed
> -----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12571
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12571
>             Project: Groovy
>          Issue Type: Bug
>          Components: async
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> import groovy.concurrent.BroadcastChannel
> def broadcast = BroadcastChannel.create()
> broadcast.close()
> for await (x in broadcast.asPublisher()) { println x } // 
> ChannelClosedException; expected: ends without values
> {code}
> A subscriber that arrives after {{close()}} gets 
> {{onError(ChannelClosedException)}}, and after {{close(failure)}} it gets the 
> wrapper rather than the failure. A subscriber attached a moment before the 
> close completes, or receives the failure itself, so the same program finishes 
> or fails depending on timing. Expected: as {{SubmissionPublisher}}, 
> {{Agent.changes()}} and {{for await}} over a closed {{AsyncChannel}} behave, 
> a late subscriber gets {{onComplete}} after {{close()}} and 
> {{onError(failure)}} after {{close(failure)}}. 
> {{BroadcastChannel.subscribe()}} still throws once closed.
> Behaviour change from 6.0.0: code that caught {{ChannelClosedException}} from 
> a publisher of a closed broadcast now sees {{onComplete}} after {{close()}}, 
> or {{onError}} with the failure itself after {{close(failure)}}. The PR adds 
> a COMPATIBILITY.md entry.
> PR: https://github.com/apache/groovy/pull/3105



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to