Skip to content

Commit 9a39e5e

Browse files
author
Federico Fissore
committed
Some configuration may totally miss network interfaces, even localhost. Fixes arduino#4249
1 parent a284871 commit 9a39e5e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arduino-core/src/cc/arduino/packages/discoverers/network/NetworkChecker.java

+13
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import javax.jmdns.NetworkTopologyDiscovery;
3333
import java.net.InetAddress;
34+
import java.net.NetworkInterface;
35+
import java.net.SocketException;
3436
import java.util.*;
3537

3638
public class NetworkChecker extends TimerTask {
@@ -53,6 +55,9 @@ public void start(Timer timer) {
5355

5456
@Override
5557
public void run() {
58+
if (!hasNetworkInterfaces()) {
59+
return;
60+
}
5661
try {
5762
InetAddress[] curentAddresses = topology.getInetAddresses();
5863
Set<InetAddress> current = new HashSet<>(curentAddresses.length);
@@ -68,4 +73,12 @@ public void run() {
6873
e.printStackTrace();
6974
}
7075
}
76+
77+
private boolean hasNetworkInterfaces() {
78+
try {
79+
return NetworkInterface.getNetworkInterfaces() != null;
80+
} catch (SocketException e) {
81+
return false;
82+
}
83+
}
7184
}

0 commit comments

Comments
 (0)