diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2009-09-15 19:37:54 -0700 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2009-09-15 19:41:53 -0700 |
commit | 88e341d4cbfd085e2f16659e810c95ba88bd608d (patch) | |
tree | c48bd41638ae925e95db141eec61410054d87a05 /luni | |
parent | a9680775a244c99a2591c0b95d45efa85ee977ae (diff) | |
download | libcore-88e341d4cbfd085e2f16659e810c95ba88bd608d.zip libcore-88e341d4cbfd085e2f16659e810c95ba88bd608d.tar.gz libcore-88e341d4cbfd085e2f16659e810c95ba88bd608d.tar.bz2 |
Report the cause of name lookup failures to Java land. The Java code already
uses the exception thrown by getallbyname() as a chained exception.
Change-Id: Ifc0d34102412ce0bf34715c9852bf751b420fb40
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/native/java_net_InetAddress.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/luni/src/main/native/java_net_InetAddress.cpp b/luni/src/main/native/java_net_InetAddress.cpp index 90a88ee..d7b4931 100644 --- a/luni/src/main/native/java_net_InetAddress.cpp +++ b/luni/src/main/native/java_net_InetAddress.cpp @@ -100,7 +100,10 @@ static jobjectArray getAllByNameUsingAdb(JNIEnv* env, const char* name) env->SetByteArrayRegion(byteArray, 0, 4, (jbyte*) &outaddr.s_addr); env->SetObjectArrayElement(addressArray, 1, byteArray); } + } else { + jniThrowException(env, "java/net/UnknownHostException", "adb error"); } + return addressArray; } @@ -189,8 +192,8 @@ static jobjectArray getAllByNameUsingDns(JNIEnv* env, const char* name, env, "java/lang/SecurityException", "Permission denied (maybe missing INTERNET permission)"); } else { - // Do nothing. Return value will be null and the caller will throw an - // UnknownHostExeption. + jniThrowException(env, "java/net/UnknownHostException", + gai_strerror(result)); } if (addressList) { @@ -227,12 +230,6 @@ jobjectArray InetAddress_getallbyname(JNIEnv* env, jobject obj, out = getAllByNameUsingDns(env, name, preferIPv4Stack); } - if (!out) { -#if LOG_DNS - LOGI("Unknown host %s, throwing UnknownHostException", name); -#endif - jniThrowException(env, "java/net/UnknownHostException", name); - } env->ReleaseStringUTFChars(javaName, name); return out; } |