Skip to content

Commit

Permalink
Fixes HttpClientOperations to don't offload `onSubscribe(subscription…
Browse files Browse the repository at this point in the history
…)` (#1189)

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
  • Loading branch information
OlegDokuka authored and violetagg committed Jun 29, 2020
1 parent 5e4bc03 commit 49387fa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/reactor/netty/http/client/HttpClientOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import io.netty.handler.stream.ChunkedWriteHandler;
import io.netty.util.ReferenceCountUtil;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Disposable;
import reactor.core.Exceptions;
Expand Down Expand Up @@ -761,6 +762,13 @@ static final class SendForm extends Mono<Void> {

@Override
public void subscribe(CoreSubscriber<? super Void> s) {
if (!parent.markSentHeaders()) {
Operators.error(s,
new IllegalStateException("headers have already been sent"));
return;
}
Subscription subscription = Operators.emptySubscription();
s.onSubscribe(subscription);
if (parent.channel()
.eventLoop()
.inEventLoop()) {
Expand All @@ -775,12 +783,6 @@ public void subscribe(CoreSubscriber<? super Void> s) {

@SuppressWarnings("FutureReturnValueIgnored")
void _subscribe(CoreSubscriber<? super Void> s) {
if (!parent.markSentHeaders()) {
Operators.error(s,
new IllegalStateException("headers have already been sent"));
return;
}

HttpDataFactory df = DEFAULT_FACTORY;

try {
Expand Down Expand Up @@ -837,14 +839,14 @@ void _subscribe(CoreSubscriber<? super Void> s) {
.flux());
}
}
Operators.complete(s);
s.onComplete();


}
catch (Throwable e) {
Exceptions.throwIfJvmFatal(e);
df.cleanRequestHttpData(parent.nettyRequest);
Operators.error(s, Exceptions.unwrap(e));
s.onError(Exceptions.unwrap(e));
}
}
}
Expand Down

0 comments on commit 49387fa

Please sign in to comment.