Skip to content

LoadVIDPIDSpecificPreferences fails when connected board returns no string text #3738

@logan893

Description

@logan893

I'm receiving the following error with the newly downloaded Arduino IDE 1.6.5-r4, when compiling any sketch.

java.lang.NullPointerException
at cc.arduino.LoadVIDPIDSpecificPreferences.load(LoadVIDPIDSpecificPreferences.java:48)
at processing.app.debug.Compiler.createBuildPreferences(Compiler.java:592)
at processing.app.debug.Compiler.(Compiler.java:193)
at processing.app.debug.Compiler.build(Compiler.java:96)
at processing.app.Sketch.build(Sketch.java:1109)
at processing.app.Sketch.build(Sketch.java:1084)
at processing.app.Editor$BuildHandler.run(Editor.java:1955)
at java.lang.Thread.run(Thread.java:745)

I need to have my Arduino Pro Mini board (most likely a Chinese knock-off) connected via USB and have that COM port selected for this error to show up. The port shows up as e.g. COM4, with no additional parenthesis like my Arduino Uno which shows up as COM7 (Arduino Uno).

Disconnecting this device (i.e. selecting none), or connecting and selecting my Arduino Uno, allows me to compile.

Source file at fault:
https://github.com/arduino/Arduino/blob/1.6.5-r4/arduino-core/src/cc/arduino/LoadVIDPIDSpecificPreferences.java

This file is new as of 1.6.5-r4

Line 48:
int VIDPIDIndex = findVIDPIDIndex(prefs, boardPort.getPrefs().get("vid").toUpperCase(), boardPort.getPrefs().get("pid").toUpperCase());

One, or likely both, of the boardPort.getPrefs().get(String) functions returns null, which throws this exception when calling .toUpperCase() on a null value (default return value from java.util.LinkedHashMap.get() when no match is found).

Possible suggestion to fix this (you likely know better if this has any other side effects); use a default option for the get() function of PreferencesMap data structure.
int VIDPIDIndex = findVIDPIDIndex(prefs, boardPort.getPrefs().get("vid","").toUpperCase(), boardPort.getPrefs().get("pid","").toUpperCase());

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions