From 40e9aa17b30de0b3e78847e4c102333d138b3a13 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 21 Jan 2016 17:15:42 +0100 Subject: [PATCH] Fix file descriptor leak when downloads are interrupted This fixes a java warning. --- arduino-core/src/cc/arduino/utils/network/FileDownloader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java index 4d090283d..2702767db 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java @@ -207,8 +207,10 @@ public class FileDownloader extends Observable { file.write(buffer, 0, read); setDownloaded(getDownloaded() + read); - if (Thread.interrupted()) + if (Thread.interrupted()) { + file.close(); throw new InterruptedException(); + } } if (getDownloadSize() != null) {