Summary
Modify the specifications of the java.nio.file.FileStore
methods getUsableSpace
and getUnallocatedSpace
to clarify that the returned values are current as of when the method is invoked.
Problem
It is not clear enough from the existing specifications of the methods in question that the values might not have been determined up front when the FileStore
was created.
Solution
Make it clear that the returned space values are valid as of the time of the method call.
Specification
--- a/src/java.base/share/classes/java/nio/file/FileStore.java
+++ b/src/java.base/share/classes/java/nio/file/FileStore.java
@@ -103,11 +103,11 @@ protected FileStore() {
* <p> The returned number of available bytes is a hint, but not a
* guarantee, that it is possible to use most or any of these bytes. The
* number of usable bytes is most likely to be accurate immediately
- * after the space attributes are obtained. It is likely to be made inaccurate
+ * after this method returns. It is likely to be made inaccurate
* by any external I/O operations including those made on the system outside
* of this Java virtual machine.
*
- * @return the number of bytes available
+ * @return the current number of usable bytes
*
* @throws IOException
* if an I/O error occurs
@@ -122,11 +122,11 @@ protected FileStore() {
* <p> The returned number of unallocated bytes is a hint, but not a
* guarantee, that it is possible to use most or any of these bytes. The
* number of unallocated bytes is most likely to be accurate immediately
- * after the space attributes are obtained. It is likely to be
+ * after this method returns. It is likely to be
* made inaccurate by any external I/O operations including those made on
* the system outside of this virtual machine.
*
- * @return the number of unallocated bytes
+ * @return the current number of unallocated bytes
*
* @throws IOException
* if an I/O error occurs
- csr of
-
JDK-7057369 (fs spec) FileStore getUsableSpace and getUnallocatedSpace could be clearer
- Resolved