From db5809f968aa31816bbad5f84b1e4307a2f9a31a Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 22 May 2025 17:23:35 +0200 Subject: [PATCH] =?UTF-8?q?Remove=20obsolete=20@=E2=81=A0Contract=20declar?= =?UTF-8?q?ation=20for=20StreamUtils.drain()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes gh-34933 --- .../org/springframework/util/StreamUtils.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/StreamUtils.java b/spring-core/src/main/java/org/springframework/util/StreamUtils.java index 354e7b2cf20..36fd4de5ad9 100644 --- a/spring-core/src/main/java/org/springframework/util/StreamUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StreamUtils.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. @@ -25,13 +25,14 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.Charset; -import org.springframework.lang.Contract; import org.springframework.lang.Nullable; /** - * Simple utility methods for dealing with streams. The copy methods of this class are - * similar to those defined in {@link FileCopyUtils} except that all affected streams are - * left open when done. All copy methods use a block size of 8192 bytes. + * Simple utility methods for dealing with streams. + * + *
The copy methods of this class are similar to those defined in + * {@link FileCopyUtils} except that all affected streams are left open when done. + * All copy methods use a block size of {@value #BUFFER_SIZE} bytes. * *
Mainly for use within the framework, but also useful for application code. * @@ -190,14 +191,14 @@ public abstract class StreamUtils { } /** - * Drain the remaining content of the given InputStream. - *
Leaves the InputStream open when done. - * @param in the InputStream to drain - * @return the number of bytes read + * Drain the remaining content of the given {@link InputStream}. + *
Leaves the {@code InputStream} open when done. + * @param in the {@code InputStream} to drain + * @return the number of bytes read, or {@code 0} if the supplied + * {@code InputStream} is {@code null} or empty * @throws IOException in case of I/O errors * @since 4.3 */ - @Contract("null -> fail") public static int drain(@Nullable InputStream in) throws IOException { if (in == null) { return 0;