From 08ea1cc481fe1e971105d71fc1a28be0bb1abe19 Mon Sep 17 00:00:00 2001 From: ted Date: Sat, 11 Apr 2020 16:46:24 -0700 Subject: [PATCH 1/2] Check for nulls when using programmer Try to test and gracefully fail rather than throwing a NullPointerException. See #10032 for an example of this exception being thrown. --- .../src/cc/arduino/packages/uploaders/SerialUploader.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java index 96ba383aceb..98055bed6ee 100644 --- a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java +++ b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java @@ -280,12 +280,18 @@ private String waitForUploadPort(String uploadPort, List before, boolean private boolean uploadUsingProgrammer(String buildPath, String className) throws Exception { TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); + if (targetPlatform == null) { + throw new RunnerException(tr("Gould not load platform for programmer. Ensure programmer selection is correct for the board."), false); + } String programmer = PreferencesData.get("programmer"); if (programmer.contains(":")) { String[] split = programmer.split(":", 2); targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]); programmer = split[1]; } + if (programmer == null) { + throw new RunnerException(tr("Gould not load programmer. Ensure programmer selection is correct for the board."), false); + } PreferencesMap prefs = PreferencesData.getMap(); PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences(); From db872fc81ab8782c50f27a94416e28780eadfb18 Mon Sep 17 00:00:00 2001 From: ted Date: Sun, 12 Apr 2020 21:15:24 -0700 Subject: [PATCH 2/2] Fix typo in string --- .../src/cc/arduino/packages/uploaders/SerialUploader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java index 98055bed6ee..98f34baf173 100644 --- a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java +++ b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java @@ -281,7 +281,7 @@ private boolean uploadUsingProgrammer(String buildPath, String className) throws TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); if (targetPlatform == null) { - throw new RunnerException(tr("Gould not load platform for programmer. Ensure programmer selection is correct for the board."), false); + throw new RunnerException(tr("Could not load platform for programmer. Ensure programmer selection is correct for the board."), false); } String programmer = PreferencesData.get("programmer"); if (programmer.contains(":")) { @@ -290,7 +290,7 @@ private boolean uploadUsingProgrammer(String buildPath, String className) throws programmer = split[1]; } if (programmer == null) { - throw new RunnerException(tr("Gould not load programmer. Ensure programmer selection is correct for the board."), false); + throw new RunnerException(tr("Could not load programmer. Ensure programmer selection is correct for the board."), false); } PreferencesMap prefs = PreferencesData.getMap();