Skip to content

Commit

Permalink
Be paranoid about exceptions in the WebDriverException itself
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Feb 15, 2017
1 parent cb00152 commit f7b68e7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions java/client/src/org/openqa/selenium/WebDriverException.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@
import org.openqa.selenium.internal.BuildInfo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -67,18 +64,18 @@ public class WebDriverException extends RuntimeException {
host = reader.readLine();
}
}
} catch (IOException ignored) {
// Do nothing and fall through
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (Exception e) {
// fall through
}
}
if (host == null) {
// Give up.
try {
host = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
} catch (Exception e) {
host = "Unknown"; // At least we tried.
}
}
Expand All @@ -96,15 +93,15 @@ public class WebDriverException extends RuntimeException {
address = inetAddress.getHostAddress();
break;
}
} catch (SocketException e) {
} catch (Exception e) {
// Fall through and go the slow way.
}
}
if (address == null) {
// Alright. I give up.
try {
address = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
} catch (Exception e) {
address = "Unknown";
}
}
Expand Down

0 comments on commit f7b68e7

Please sign in to comment.