mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
ensure proper closing of Stream in arcane UI
This commit is contained in:
parent
a0a2ac1b5a
commit
63dbfb8a9b
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
package org.mage.card.arcane;
|
package org.mage.card.arcane;
|
||||||
|
|
||||||
|
import mage.utils.StreamUtils;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
@ -72,8 +74,8 @@ public final class UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageIcon getImageIcon (String path) {
|
public static ImageIcon getImageIcon (String path) {
|
||||||
|
InputStream stream = null;
|
||||||
try {
|
try {
|
||||||
InputStream stream;
|
|
||||||
stream = UI.class.getResourceAsStream(path);
|
stream = UI.class.getResourceAsStream(path);
|
||||||
if (stream == null && new File(path).exists()) {
|
if (stream == null && new File(path).exists()) {
|
||||||
stream = new FileInputStream(path);
|
stream = new FileInputStream(path);
|
||||||
|
@ -86,6 +88,8 @@ public final class UI {
|
||||||
return new ImageIcon(data);
|
return new ImageIcon(data);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new RuntimeException("Error reading image: " + path);
|
throw new RuntimeException("Error reading image: " + path);
|
||||||
|
} finally {
|
||||||
|
StreamUtils.closeQuietly(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue