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 48c47926c0..33e92d4116 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.jspecify.annotations.Nullable; @@ -102,6 +103,7 @@ final class SimpleClientHttpResponse implements ClientHttpResponse { if (this.responseStream == null) { getBody(); } + Objects.requireNonNull(this.responseStream); StreamUtils.drain(this.responseStream); this.responseStream.close(); }