diff options
| author | Charles Munger <clm@google.com> | 2019-11-15 12:55:55 -0800 |
|---|---|---|
| committer | Charles Munger <clm@google.com> | 2019-11-15 21:12:39 +0000 |
| commit | 219e986e294e9cc8ed8ebf89038df95cd95e17bd (patch) | |
| tree | 05bb1ababc8dd36f5fdb90405abcd20b95ce9562 /core/java/android/os/FileUtils.java | |
| parent | 8e54615a36c2ca5abe91b767ff44c54af19081d3 (diff) | |
Deprecate FileUtils.closeQuietly
This API encourages swallowing errors, and the code to implement it is trivial if apps still want to do it themselves.
Guava's reasoning on deprecating their version of this API:
https://github.com/google/guava/issues/1118
Test: No behavior changes
Bug: 144042891
Change-Id: Ic4cfb7366c65d49c355479f420d9ba4fc1b3f053
Diffstat (limited to 'core/java/android/os/FileUtils.java')
| -rw-r--r-- | core/java/android/os/FileUtils.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index f789b723f732..2ac3def3a3f9 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -1275,7 +1275,13 @@ public final class FileUtils { /** * Closes the given object quietly, ignoring any checked exceptions. Does * nothing if the given object is {@code null}. + * + * @deprecated This method may suppress potentially significant exceptions, particularly when + * closing writable resources. With a writable resource, a failure thrown from {@code close()} + * should be considered as significant as a failure thrown from a write method because it may + * indicate a failure to flush bytes to the underlying resource. */ + @Deprecated public static void closeQuietly(@Nullable AutoCloseable closeable) { IoUtils.closeQuietly(closeable); } @@ -1283,7 +1289,13 @@ public final class FileUtils { /** * Closes the given object quietly, ignoring any checked exceptions. Does * nothing if the given object is {@code null}. + * + * @deprecated This method may suppress potentially significant exceptions, particularly when + * closing writable resources. With a writable resource, a failure thrown from {@code close()} + * should be considered as significant as a failure thrown from a write method because it may + * indicate a failure to flush bytes to the underlying resource. */ + @Deprecated public static void closeQuietly(@Nullable FileDescriptor fd) { IoUtils.closeQuietly(fd); } |
