1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

PluggableDiscovery: BoardPort.label sanity check in the correct place

This commit is contained in:
Cristian Maglie 2018-11-30 12:06:23 +01:00
parent 4c188c9374
commit 4ae740ad66

View File

@ -173,6 +173,10 @@ public class PluggableDiscovery implements Discovery {
private BoardPort mapJsonNodeToBoardPort(ObjectMapper mapper, JsonNode node) {
try {
BoardPort port = mapper.treeToValue(node.get("port"), BoardPort.class);
// if no label, use address
if (port.getLabel() == null || port.getLabel().isEmpty()) {
port.setLabel(port.getAddress());
}
port.searchMatchingBoard();
return port;
} catch (JsonProcessingException e) {
@ -256,10 +260,6 @@ public class PluggableDiscovery implements Discovery {
// if address already on the list, discard old info
portList.removeIf(bp -> address.equals(bp.getAddress()));
// if no label, use address
if (port.getLabel() == null) {
port.setLabel(address);
}
portList.add(port);
}