Is the not null assertion necessary here? It seems like a dead code.
In org.springframework.http.server.reactive.ReactorServerHttpResponse
, line 59, if the response is null, JVM will throw NPE at line 58 and never go to line 59. The assertion will not throw IllegalArgumentException with the specific message at any time.
public ReactorServerHttpResponse(HttpServerResponse response, DataBufferFactory bufferFactory) {
super(bufferFactory, new HttpHeaders(new NettyHeadersAdapter(response.responseHeaders())));
Assert.notNull(response, "HttpServerResponse must not be null");
this.response = response;
}
https://github.com/spring-projects/spring-framework/blob/842569c9e519ec7d11fc86691577cee067c7ef47/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpResponse.java#L59
Comment From: sbrannen
- superseded by #30696
Comment From: sbrannen
Hi @firestige,
Congratulations on reporting your first issue for the Spring Framework! 👍
Is the not null assertion necessary here? It seems like a dead code.
Yes, good catch. This will be addressed in #30696.