Skip to content

Commit 4b85b44

Browse files
committed
Update Javadoc of InputStreamResource#contentLength
Closes gh-20990
1 parent fa5e848 commit 4b85b44

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-core/src/main/java/org/springframework/core/io/AbstractResource.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -150,9 +150,11 @@ public ReadableByteChannel readableChannel() throws IOException {
150150
}
151151

152152
/**
153-
* This implementation reads the entire InputStream to calculate the
154-
* content length. Subclasses will almost always be able to provide
155-
* a more optimal version of this, e.g. checking a File length.
153+
* This method reads the entire InputStream to determine the content length.
154+
* <p>For a custom sub-class of {@code InputStreamResource}, we strongly
155+
* recommend overriding this method with a more optimal implementation, e.g.
156+
* checking File length, or possibly simply returning -1 if the stream can
157+
* only be read once.
156158
* @see #getInputStream()
157159
*/
158160
@Override

0 commit comments

Comments
 (0)