From 40e9aa17b30de0b3e78847e4c102333d138b3a13 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 21 Jan 2016 17:15:42 +0100 Subject: [PATCH 1/3] 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) { From 82d3985f6fde5d530e7dcbd7925871e576f9e6f1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 21 Jan 2016 17:16:50 +0100 Subject: [PATCH 2/3] Remove `I18n._()` This function was already deprecated and still triggers a java warning. Removing it silences that. --- arduino-core/src/processing/app/I18n.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arduino-core/src/processing/app/I18n.java b/arduino-core/src/processing/app/I18n.java index 72b67a8ec..0ab961aa9 100644 --- a/arduino-core/src/processing/app/I18n.java +++ b/arduino-core/src/processing/app/I18n.java @@ -70,11 +70,6 @@ public class I18n { PROMPT_BROWSE = tr("Browse"); } - @Deprecated - public static String _(String s) { - return tr(s); - } - public static String tr(String s) { String res; try { From 3d47995915e08b4ba07a828b562fb6342ed858c6 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 21 Jan 2016 17:18:55 +0100 Subject: [PATCH 3/3] Remove unused imports This silences some java warnings. --- app/src/processing/app/Sketch.java | 1 - .../packages/uploaders/GenericNetworkUploader.java | 2 -- arduino-core/src/processing/app/SketchCode.java | 1 - arduino-core/src/processing/app/linux/Platform.java | 8 -------- arduino-core/src/processing/app/macosx/Platform.java | 2 -- arduino-core/src/processing/app/windows/Platform.java | 8 -------- 6 files changed, 22 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 444888c90..ecbd54938 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -27,7 +27,6 @@ import cc.arduino.Compiler; import cc.arduino.CompilerProgressListener; import cc.arduino.UploaderUtils; import cc.arduino.packages.Uploader; -import org.apache.commons.codec.digest.DigestUtils; import processing.app.debug.RunnerException; import processing.app.forms.PasswordAuthorizationDialog; import processing.app.helpers.FileUtils; diff --git a/arduino-core/src/cc/arduino/packages/uploaders/GenericNetworkUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/GenericNetworkUploader.java index 3a7cabf49..1bc5befe4 100644 --- a/arduino-core/src/cc/arduino/packages/uploaders/GenericNetworkUploader.java +++ b/arduino-core/src/cc/arduino/packages/uploaders/GenericNetworkUploader.java @@ -38,8 +38,6 @@ import processing.app.helpers.StringReplacer; import java.io.File; import java.util.List; -import static processing.app.I18n.tr; - public class GenericNetworkUploader extends Uploader { private final BoardPort port; diff --git a/arduino-core/src/processing/app/SketchCode.java b/arduino-core/src/processing/app/SketchCode.java index 3e1858676..db0f95af0 100644 --- a/arduino-core/src/processing/app/SketchCode.java +++ b/arduino-core/src/processing/app/SketchCode.java @@ -28,7 +28,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; diff --git a/arduino-core/src/processing/app/linux/Platform.java b/arduino-core/src/processing/app/linux/Platform.java index f28df3555..505b9cf88 100644 --- a/arduino-core/src/processing/app/linux/Platform.java +++ b/arduino-core/src/processing/app/linux/Platform.java @@ -22,18 +22,10 @@ package processing.app.linux; -import org.apache.commons.exec.CommandLine; -import org.apache.commons.exec.DefaultExecutor; -import org.apache.commons.exec.Executor; -import org.apache.commons.exec.PumpStreamHandler; import processing.app.PreferencesData; -import processing.app.debug.TargetPackage; import processing.app.legacy.PConstants; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; -import java.util.Map; /** diff --git a/arduino-core/src/processing/app/macosx/Platform.java b/arduino-core/src/processing/app/macosx/Platform.java index 7c0768823..0325b5d50 100644 --- a/arduino-core/src/processing/app/macosx/Platform.java +++ b/arduino-core/src/processing/app/macosx/Platform.java @@ -29,7 +29,6 @@ import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.Executor; import org.apache.commons.exec.PumpStreamHandler; import org.apache.commons.lang3.StringUtils; -import processing.app.debug.TargetPackage; import processing.app.legacy.PApplet; import processing.app.legacy.PConstants; @@ -41,7 +40,6 @@ import java.io.IOException; import java.net.URI; import java.util.LinkedList; import java.util.List; -import java.util.Map; /** diff --git a/arduino-core/src/processing/app/windows/Platform.java b/arduino-core/src/processing/app/windows/Platform.java index 1783a1760..790be03ed 100644 --- a/arduino-core/src/processing/app/windows/Platform.java +++ b/arduino-core/src/processing/app/windows/Platform.java @@ -24,16 +24,9 @@ package processing.app.windows; import cc.arduino.os.windows.FolderFinderInWindowsEnvVar; import cc.arduino.os.windows.FolderFinderInWindowsRegistry; -import org.apache.commons.exec.CommandLine; -import org.apache.commons.exec.DefaultExecutor; -import org.apache.commons.exec.Executor; -import org.apache.commons.exec.PumpStreamHandler; -import processing.app.BaseNoGui; -import processing.app.debug.TargetPackage; import processing.app.legacy.PApplet; import processing.app.legacy.PConstants; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -41,7 +34,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.LinkedList; import java.util.List; -import java.util.Map; public class Platform extends processing.app.Platform {