ensure proper closing of Stream in arcane UI

This commit is contained in:
Marc Zwart 2018-03-20 14:48:22 +01:00
parent a0a2ac1b5a
commit 63dbfb8a9b

View file

@ -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);
}
}