Propagate Reactor Context when using FluxSink

This commit makes sure that the Reactor context from a given mono or
flux is propagated to the Flux returned by a FluxSink. This change
affects both DataBufferUtils::write and internal classes used by the
DefaultPartHttpMessageReader.

Closes gh-27517
This commit is contained in:
Arjen Poutsma
2021-10-05 16:20:30 +02:00
parent 7b9848a352
commit c99210c01f
4 changed files with 74 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SynchronousSink;
import reactor.util.context.Context;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
@@ -1057,6 +1058,12 @@ public abstract class DataBufferUtils {
protected void hookOnComplete() {
this.sink.complete();
}
@Override
public Context currentContext() {
return this.sink.currentContext();
}
}
@@ -1148,6 +1155,12 @@ public abstract class DataBufferUtils {
this.sink.next(dataBuffer);
this.dataBuffer.set(null);
}
@Override
public Context currentContext() {
return this.sink.currentContext();
}
}
}