1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-27 04:22:07 +03:00

Don't explode if we can't find an interface for a local address.

We'll likely explode later when attempting to use the socket.
But that will fail with an IOException, unlike this which was
failing with a NullPointerException.
This commit is contained in:
jwilson
2013-04-29 17:20:54 -04:00
parent 6abac65309
commit 63c5a42ecd

View File

@@ -201,6 +201,9 @@ public class Platform {
try {
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
socket.getLocalAddress());
if (networkInterface == null) {
return super.getMtu(socket); // There's no longer an interface with this local address.
}
return (Integer) getMtu.invoke(networkInterface);
} catch (IllegalAccessException e) {
throw new AssertionError(e);