Skip to content

Commit db5809f

Browse files
committed
Remove obsolete @⁠Contract declaration for StreamUtils.drain()
Closes gh-34933
1 parent d890a38 commit db5809f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

spring-core/src/main/java/org/springframework/util/StreamUtils.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,13 +25,14 @@
2525
import java.io.OutputStream;
2626
import java.nio.charset.Charset;
2727

28-
import org.springframework.lang.Contract;
2928
import org.springframework.lang.Nullable;
3029

3130
/**
32-
* Simple utility methods for dealing with streams. The copy methods of this class are
33-
* similar to those defined in {@link FileCopyUtils} except that all affected streams are
34-
* left open when done. All copy methods use a block size of 8192 bytes.
31+
* Simple utility methods for dealing with streams.
32+
*
33+
* <p>The copy methods of this class are similar to those defined in
34+
* {@link FileCopyUtils} except that all affected streams are left open when done.
35+
* All copy methods use a block size of {@value #BUFFER_SIZE} bytes.
3536
*
3637
* <p>Mainly for use within the framework, but also useful for application code.
3738
*
@@ -190,14 +191,14 @@ public static long copyRange(InputStream in, OutputStream out, long start, long
190191
}
191192

192193
/**
193-
* Drain the remaining content of the given InputStream.
194-
* <p>Leaves the InputStream open when done.
195-
* @param in the InputStream to drain
196-
* @return the number of bytes read
194+
* Drain the remaining content of the given {@link InputStream}.
195+
* <p>Leaves the {@code InputStream} open when done.
196+
* @param in the {@code InputStream} to drain
197+
* @return the number of bytes read, or {@code 0} if the supplied
198+
* {@code InputStream} is {@code null} or empty
197199
* @throws IOException in case of I/O errors
198200
* @since 4.3
199201
*/
200-
@Contract("null -> fail")
201202
public static int drain(@Nullable InputStream in) throws IOException {
202203
if (in == null) {
203204
return 0;

0 commit comments

Comments
 (0)