`.mapConnect()` and `.doOnRequestError()` are not called when `.headersWhen()` is used
mateuszrzeszutek opened this issue · comments
Expected Behavior
I would expect that the HTTP client executes its callbacks regardless of whether the headers were set using .headersWhen()
or headers()
. Currently this is not the case, .mapConnect()
and .doOnRequestError()
callbacks are not executed when deferred config is used.
Actual Behavior
.mapConnect()
and .doOnRequestError()
callbacks are not executed when deferred config is used.
Steps to Reproduce
This test prints out the two messages to stdout:
@Test
void headers() {
HttpClient.create()
.headers(h -> h.set("test", "test"))
.mapConnect(connection -> {
System.out.println("mapConnect()");
return connection;
})
.doOnRequestError((request, throwable) -> System.out.println("doOnRequestError()"))
.get()
.uri("http://192.0.2.1")
.response()
.block();
}
This one does not:
@Test
void headersWhen() {
HttpClient.create()
.headersWhen(h -> Mono.just(h.set("test", "test")))
.mapConnect(connection -> {
System.out.println("mapConnect()");
return connection;
})
.doOnRequestError((request, throwable) -> System.out.println("doOnRequestError()"))
.get()
.uri("http://192.0.2.1")
.response()
.block();
}
Possible Solution
Removing the return
in line 113 would allow the code in lines 120-133
Mono
is returned.
Your Environment
- Reactor version(s) used: this happens on any version starting from 1.0
- Other relevant libraries versions (eg.
netty
, ...): - JVM version (
java -version
): OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8) - OS and version (eg.
uname -a
): Darwin Kernel Version 22.6.0
@mateuszrzeszutek Would you like to create a PR?
Sure 👍
I'll submit a fix tomorrow
Please use as a base 1.0.x
branch, later we will forward merge to main
branch.
Hey @violetagg ,
I'll need to make sure with my employer that I can sign the CLA -- it might take me a while, so unfortunately don't count on a quick fix from me.