From 1ec5a3fb4d3822f9edd20a04b3f227688f51007c Mon Sep 17 00:00:00 2001 From: Marc Zwart Date: Tue, 20 Mar 2018 15:00:08 +0100 Subject: [PATCH] ensure resource closing in deckimport from clipboard --- .../client/deckeditor/DeckImportFromClipboardDialog.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckImportFromClipboardDialog.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckImportFromClipboardDialog.java index 1eeb251ad4..eef1987dfa 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckImportFromClipboardDialog.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckImportFromClipboardDialog.java @@ -1,5 +1,7 @@ package mage.client.deckeditor; +import mage.util.StreamUtils; + import java.awt.*; import java.awt.event.*; import java.io.BufferedWriter; @@ -39,15 +41,16 @@ public class DeckImportFromClipboardDialog extends JDialog { } private void onOK() { + BufferedWriter bw = null; try { File temp = File.createTempFile("cbimportdeck", ".txt"); - BufferedWriter bw = new BufferedWriter(new FileWriter(temp)); + bw = new BufferedWriter(new FileWriter(temp)); bw.write(txtDeckList.getText()); - bw.close(); - tmpPath = temp.getPath(); } catch (IOException e) { e.printStackTrace(); + } finally { + StreamUtils.closeQuietly(bw); } dispose();