From: Niki Roo Date: Tue, 26 May 2020 19:08:11 +0000 (+0200) Subject: throw IO when image is used on close X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=commitdiff_plain;h=refs%2Fheads%2Fsubtree throw IO when image is used on close --- diff --git a/Image.java b/Image.java index 4518577..9b28835 100644 --- a/Image.java +++ b/Image.java @@ -116,7 +116,13 @@ public class Image implements Closeable, Serializable { * in case of I/O error */ public InputStream newInputStream() throws IOException { - return new MarkableFileInputStream(data); + synchronized (instanceLock) { + if (data == null) { + throw new IOException("Image was close()d"); + } + + return new MarkableFileInputStream(data); + } } /** @@ -175,6 +181,7 @@ public class Image implements Closeable, Serializable { @Override public void close() throws IOException { synchronized (instanceLock) { + new Exception().printStackTrace(); if (size >= 0) { size = -1; data.delete();