From 63c5a42ecdc53d51cc6d617d4fcc05cb2e7a9dba Mon Sep 17 00:00:00 2001 From: jwilson Date: Mon, 29 Apr 2013 17:20:54 -0400 Subject: [PATCH] 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. --- .../src/main/java/com/squareup/okhttp/internal/Platform.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java b/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java index 6b4ac343b..cabe82672 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java @@ -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);