Skip to content

Commit bf11c7f

Browse files
committed
avoid queuing a lot of threads while waiting for platform
1 parent 72c337d commit bf11c7f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ public void start(Timer timer) {
5656
}
5757

5858
public synchronized void retriggerDiscovery(boolean polled) {
59-
while (BaseNoGui.packages == null) {
60-
try {
61-
Thread.sleep(1000);
62-
} catch (InterruptedException e) {
63-
// noop
64-
}
65-
}
6659
Platform platform = BaseNoGui.getPlatform();
6760
if (platform == null) {
6861
return;
@@ -103,6 +96,11 @@ public synchronized void retriggerDiscovery(boolean polled) {
10396
String[] parts = newPort.split("_");
10497
String port = parts[0];
10598

99+
if (parts.length != 3) {
100+
// something went horribly wrong
101+
continue;
102+
}
103+
106104
Map<String, Object> boardData = platform.resolveDeviceByVendorIdProductId(port, BaseNoGui.packages);
107105

108106
BoardPort boardPort = null;
@@ -168,6 +166,9 @@ public synchronized void retriggerDiscovery(boolean polled) {
168166

169167
@Override
170168
public void run() {
169+
if (BaseNoGui.packages == null) {
170+
return;
171+
}
171172
retriggerDiscovery(true);
172173
}
173174
}

0 commit comments

Comments
 (0)