aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxianyuanjia <56282287+xianyuanjia@users.noreply.github.com>2023-08-07 10:43:58 -0700
committerGitHub <noreply@github.com>2023-08-07 10:43:58 -0700
commit9cb6d9e93baa6d4e0b8a650126a1fa3ef4c9810e (patch)
treec857e2edc1ea54ead753fabe19f05ae1337753b3
parent336c57be777d6a74733e6a55e1f96d4c0781ce5e (diff)
parent2b7dadca0346bec54a96a489c703dc53ec653452 (diff)
downloadmobly-snippet-lib-9cb6d9e93baa6d4e0b8a650126a1fa3ef4c9810e.tar.gz
Merge pull request #130 from xianyuanjia/inet
Check for null pointer in SimpleServer#getPrivateInetAddress (#130)
-rw-r--r--third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java b/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
index db7255a..54db8ae 100644
--- a/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
+++ b/third_party/sl4a/src/main/java/com/google/android/mobly/snippet/rpc/SimpleServer.java
@@ -138,6 +138,9 @@ public abstract class SimpleServer {
InetAddress candidate = null;
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
+ if (nets == null) {
+ return InetAddress.getLocalHost(); // Return local host if no interfaces found.
+ }
for (NetworkInterface netint : Collections.list(nets)) {
if (!netint.isLoopback() || !netint.isUp()) { // Ignore if localhost or not active
continue;