-
Couldn't load subscription status.
- Fork 38.8k
Description
Spring-Boot-Version: 3.3.3
In my Spring-Boot-Integration-Test i use the WebClient in an Service. I dont use any mocks in this Test-Class.
When i look into ClientRequest ( what is called as Part of initRequestBuilder()) it looks like this:
static Builder create(HttpMethod method, URI url) {
return new DefaultClientRequestBuilder(method, url);
}Only a DefaultClientRequestBuilder is created that looks like this:
public DefaultClientRequestBuilder(HttpMethod method, URI url) {
Assert.notNull(method, "HttpMethod must not be null");
Assert.notNull(url, "URI must not be null");
this.method = method;
this.url = url;
}So there should be no way that the ClientRequest is null.
But somehow i get this Error:
java.lang.NullPointerException: Cannot invoke "org.springframework.web.reactive.function.client.ClientRequest$Builder.headers(java.util.function.Consumer)" because the return value of "org.springframework.web.reactive.function.client.ClientRequest.create(org.springframework.http.HttpMethod, java.net.URI)" is null
What is special about my test:
- I use MockMvc to do an initial request to the application
- I use @DynamicPropertySource
- I use MockWebServer
What is special about this error:
- It only fails on Jenkins
Because i am not able to debug while running in Jenkins i tried debugging it locally to see whats going on.
Locally it sets the Url and the Method and it works as expected so i dont see an issue here.
Do you have an explanation for this different behaviour regarding the WebClient and especially the ClientRequest class?
I would provide you a minimal example but i dont know how to reproduce the issue.