From 1e18875725136224858e5a656e1c2de8826157b0 Mon Sep 17 00:00:00 2001 From: Marc Zwart Date: Tue, 20 Mar 2018 15:27:14 +0100 Subject: [PATCH] ensure closing of fileoutputstream in ScryfallSymbolsSource --- .../plugins/card/dl/sources/ScryfallSymbolsSource.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallSymbolsSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallSymbolsSource.java index caef7e5d211..e90d1cf9c5d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallSymbolsSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallSymbolsSource.java @@ -9,6 +9,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import mage.util.StreamUtils; import org.mage.plugins.card.dl.DownloadJob; import static org.mage.card.arcane.ManaSymbols.getSymbolFileNameAsSVG; @@ -106,20 +107,21 @@ public class ScryfallSymbolsSource implements Iterable { if (destFile.exists() && (destFile.length() > 0)){ continue; } - + FileOutputStream stream = null; try { // base64 transform String data64 = foundedData.get(searchCode); Base64.Decoder dec = Base64.getDecoder(); byte[] fileData = dec.decode(data64); - FileOutputStream stream = new FileOutputStream(destFile); + stream = new FileOutputStream(destFile); stream.write(fileData); - stream.close(); LOGGER.info("New svg symbol downloaded: " + needCode); } catch (Exception e) { LOGGER.error("Can't decode svg icon and save to file: " + destFile.getPath() + ", reason: " + e.getMessage()); + } finally { + StreamUtils.closeQuietly(stream); } } }