Skip to content

Commit 2143cfa

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 39318d7 commit 2143cfa

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
@@ -322,8 +322,9 @@ public void createFile() throws FileSystemException {
322322
}
323323

324324
if (!exists()) {
325-
getOutputStream().close();
326-
endOutput();
325+
try (FileContent content = getContent()) {
326+
content.getOutputStream().close();
327+
}
327328
}
328329
} catch (final RuntimeException re) {
329330
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
*/
@@ -92,13 +90,7 @@ public void close() throws IOException {
9290
if (exception != null) {
9391
throw exception;
9492
}
95-
try {
96-
this.closed = true;
97-
// Close the
98-
this.file.endOutput();
99-
} catch (final Exception e) {
100-
throw new FileSystemException(e);
101-
}
93+
this.closed = true;
10294
}
10395

10496
}

0 commit comments

Comments
 (0)