Skip to content

Commit 093890c

Browse files
committed
Refactor to always calling FileContent.getOutputStream
... instead of `AbstractFileObject.getOutputStream`. This allows us to not call `endOutput` explicitly from anywhere other than `DefaultFileContent`
1 parent 4b2e618 commit 093890c

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ public void createFile() throws FileSystemException {
319319
}
320320

321321
if (!exists()) {
322-
getOutputStream().close();
323-
endOutput();
322+
try (FileContent content = getContent()) {
323+
content.getOutputStream().close();
324+
}
324325
}
325326
} catch (final RuntimeException re) {
326327
throw re;

commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileOutputStream.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import java.io.IOException;
2020
import java.io.OutputStream;
2121

22-
import org.apache.commons.vfs2.FileSystemException;
23-
2422
/**
2523
* OutputStream to a RamFile.
2624
*/
@@ -57,13 +55,7 @@ public void close() throws IOException {
5755
if (exception != null) {
5856
throw exception;
5957
}
60-
try {
61-
this.closed = true;
62-
// Close the
63-
this.file.endOutput();
64-
} catch (final Exception e) {
65-
throw new FileSystemException(e);
66-
}
58+
this.closed = true;
6759
}
6860

6961
@Override

0 commit comments

Comments
 (0)