Skip to content

Commit 412fe8c

Browse files
Merge pull request #6 from SemenovAlexander/interruption-handling
Added handling for Ping interruption in synchronous mode
2 parents ae00a3c + 5d91574 commit 412fe8c

File tree

1 file changed

+7
-3
lines changed
  • library/src/main/java/com/stealthcopter/networktools/ping

1 file changed

+7
-3
lines changed

library/src/main/java/com/stealthcopter/networktools/ping/PingTools.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ public static PingResult doPing(InetAddress ia, int timeOutMillis){
2020
try{
2121
PingResult result = PingTools.doNativePing(ia, timeOutMillis);
2222
return result;
23+
} catch (InterruptedException e){
24+
PingResult pingResult = new PingResult(ia);
25+
pingResult.isReachable = false;
26+
pingResult.error="Interrupted";
27+
return pingResult;
2328
}
24-
catch (Exception e){
25-
29+
catch (Exception ignored){
2630
}
2731

2832
Log.v("AndroidNetworkTools", "Native ping failed, using java");
@@ -51,7 +55,7 @@ public static PingResult doJavaPing(InetAddress ia, int timeOutMillis){
5155
if (!reached) pingResult.error="Timed Out";
5256
} catch (IOException e) {
5357
pingResult.isReachable=false;
54-
pingResult.error="IOException";
58+
pingResult.error="IOException: "+e.getMessage();
5559
}
5660
return pingResult;
5761
}

0 commit comments

Comments
 (0)