aboutsummaryrefslogtreecommitdiff
path: root/jimfs/src/main/java
diff options
context:
space:
mode:
authorcgdecker <cgdecker@google.com>2015-01-21 08:55:41 -0800
committerColin Decker <cgdecker@google.com>2015-01-21 14:25:34 -0500
commit386a2fb1569b81a31e245e88e4792607bfaee980 (patch)
tree005d58311337581eb63a677aed027fc874e2c32f /jimfs/src/main/java
parent5fcb8799da03b9d4add5c9d0f9b8016e6f61677f (diff)
downloadjimfs-386a2fb1569b81a31e245e88e4792607bfaee980.tar.gz
Change JimfsOutputStream.flush() to do nothing rather than throw an exception when the stream is already already closed.
This matches the behavior of other core OutputStream implementations such as that returned by Files.newOutputStream(Path) for the default FileSystem and prevents an exception when nesting an OutputStream inside a BufferedOutputStream inside an OutputStreamWriter using try-with-resources under JDK8 (among any number of other situations that could cause the same problem). (Details: try-with-resources closes each declared resource in reverse order. Closing the OutputStreamWriter causes the BufferedOutputStream to be closed which causes the unbuffered OutputStream to be flushed and then closed. Closing the BufferedOutputStream then tries to flush the unbuffered OutputStream again. Prior to JDK8, any exception thrown by this flush() was swallowed and completely ignored; in JDK8, the behavior changed to (correctly) throw that exception.) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84439059
Diffstat (limited to 'jimfs/src/main/java')
-rw-r--r--jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java8
1 files changed, 1 insertions, 7 deletions
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
index 0755489..a79809c 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
@@ -89,12 +89,6 @@ final class JimfsOutputStream extends OutputStream {
}
}
- @Override
- public synchronized void flush() throws IOException {
- checkNotClosed();
- // writes are synchronous to the file, so flush does nothing
- }
-
private void checkNotClosed() throws IOException {
if (file == null) {
throw new IOException("stream is closed");
@@ -115,4 +109,4 @@ final class JimfsOutputStream extends OutputStream {
private boolean isOpen() {
return file != null;
}
-} \ No newline at end of file
+}