-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix forwarding null when CancellableMonoSink is cancelled (#11221)
Might fix #11209, will see.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
http-client/src/test/groovy/io/micronaut/http/client/netty/CancellableMonoSinkSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.micronaut.http.client.netty | ||
|
||
import org.reactivestreams.Subscriber | ||
import org.reactivestreams.Subscription | ||
import reactor.core.publisher.Mono | ||
import spock.lang.Specification | ||
|
||
class CancellableMonoSinkSpec extends Specification { | ||
def "cancel before request"() { | ||
given: | ||
def sink = new CancellableMonoSink<String>(null) | ||
def result = "unset" | ||
Subscription subscription = null | ||
sink.subscribe(new Subscriber<String>() { | ||
@Override | ||
void onSubscribe(Subscription s) { | ||
subscription = s | ||
} | ||
|
||
@Override | ||
void onNext(String s) { | ||
result = s | ||
} | ||
|
||
@Override | ||
void onError(Throwable t) { | ||
} | ||
|
||
@Override | ||
void onComplete() { | ||
} | ||
}) | ||
|
||
when: | ||
sink.cancel() | ||
subscription.request(1) | ||
|
||
then: | ||
result == "unset" | ||
} | ||
} |