From 63dbfb8a9b458b1e18c46ae5c9cb9faf3196ca29 Mon Sep 17 00:00:00 2001 From: Marc Zwart Date: Tue, 20 Mar 2018 14:48:22 +0100 Subject: [PATCH] ensure proper closing of Stream in arcane UI --- Mage.Client/src/main/java/org/mage/card/arcane/UI.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java index 0b2ed25f00..d07264d8a8 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/UI.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/UI.java @@ -1,5 +1,7 @@ package org.mage.card.arcane; +import mage.utils.StreamUtils; + import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -72,8 +74,8 @@ public final class UI { } public static ImageIcon getImageIcon (String path) { + InputStream stream = null; try { - InputStream stream; stream = UI.class.getResourceAsStream(path); if (stream == null && new File(path).exists()) { stream = new FileInputStream(path); @@ -86,6 +88,8 @@ public final class UI { return new ImageIcon(data); } catch (IOException ex) { throw new RuntimeException("Error reading image: " + path); + } finally { + StreamUtils.closeQuietly(stream); } }