From 679c6a1f7a9a13c186af996349e23fc97ac20997 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 26 May 2020 21:08:11 +0200 Subject: [PATCH] throw IO when image is used on close --- Image.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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(); -- 2.27.0