|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
27 | 27 |
|
28 | 28 | import org.jspecify.annotations.Nullable;
|
29 | 29 |
|
30 |
| -import org.springframework.lang.Contract; |
31 |
| - |
32 | 30 | /**
|
33 |
| - * Simple utility methods for dealing with streams. The copy methods of this class are |
34 |
| - * similar to those defined in {@link FileCopyUtils} except that all affected streams are |
35 |
| - * 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. |
36 | 36 | *
|
37 | 37 | * <p>Mainly for use within the framework, but also useful for application code.
|
38 | 38 | *
|
@@ -191,14 +191,14 @@ public static long copyRange(InputStream in, OutputStream out, long start, long
|
191 | 191 | }
|
192 | 192 |
|
193 | 193 | /**
|
194 |
| - * Drain the remaining content of the given InputStream. |
195 |
| - * <p>Leaves the InputStream open when done. |
196 |
| - * @param in the InputStream to drain |
197 |
| - * @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 |
198 | 199 | * @throws IOException in case of I/O errors
|
199 | 200 | * @since 4.3
|
200 | 201 | */
|
201 |
| - @Contract("null -> fail") |
202 | 202 | public static int drain(@Nullable InputStream in) throws IOException {
|
203 | 203 | if (in == null) {
|
204 | 204 | return 0;
|
|
0 commit comments