diff --git a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java index b8fa7acc91..de327d7e1c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -150,9 +150,11 @@ public abstract class AbstractResource implements Resource { } /** - * This implementation reads the entire InputStream to calculate the - * content length. Subclasses will almost always be able to provide - * a more optimal version of this, e.g. checking a File length. + * This method reads the entire InputStream to determine the content length. + *
For a custom sub-class of {@code InputStreamResource}, we strongly + * recommend overriding this method with a more optimal implementation, e.g. + * checking File length, or possibly simply returning -1 if the stream can + * only be read once. * @see #getInputStream() */ @Override