Skip to content

Commit 3834df7

Browse files
author
Gabriel Einsdorf
committed
FileHandle: don't unnecessarily init a RandomAccessFile on close
If we close a handle on a file that does not exist, we do not need to initialize the RandomAccessFile, just to close it again. This fixes the problem of empty files appearing when closing a FileHandle to a file that does not exist.
1 parent 16c5f3f commit 3834df7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/scijava/io/handle/FileHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public void writeUTF(final String str) throws IOException {
290290

291291
@Override
292292
public void close() throws IOException {
293-
raf().close();
293+
if (raf != null) raf().close();
294294
}
295295

296296
// -- Typed methods --

0 commit comments

Comments
 (0)