diff --git a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java index 728871cddd..56a953a23a 100644 --- a/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.http.client; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; +import java.util.Objects; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatusCode; @@ -103,6 +104,7 @@ final class SimpleClientHttpResponse implements ClientHttpResponse { if (this.responseStream == null) { getBody(); } + Objects.requireNonNull(this.responseStream); StreamUtils.drain(this.responseStream); this.responseStream.close(); }