6698625: InetAddress.getLocalHost() failed in returning chinese local host name

Remove unnecessary and incorrect NewStringUTF

Reviewed-by: michaelm
This commit is contained in:
Chris Hegarty 2008-06-12 17:25:37 +01:00
parent b572eb5b2b
commit f2e8ba353c
4 changed files with 6 additions and 31 deletions

View File

@ -138,7 +138,6 @@ JNIEXPORT jobjectArray JNICALL
Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
jobject name;
jobjectArray ret = 0;
struct hostent res, *hp = 0;
char buf[HENT_BUF_SIZE];
@ -210,12 +209,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp++;
}
name = (*env)->NewStringUTF(env, hostname);
if (IS_NULL(name)) {
goto cleanupAndReturn;
}
ret = (*env)->NewObjectArray(env, i, ni_iacls, NULL);
if (IS_NULL(ret)) {
/* we may have memory to free at the end of this */
@ -231,7 +224,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl((*addrp)->s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, i, iaObj);
addrp++;
i++;

View File

@ -142,7 +142,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
jobjectArray ret = 0;
jobject name;
int retLen = 0;
jclass byteArrayCls;
jboolean preferIPv6Address;
@ -310,11 +309,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
inet6Index = inetCount;
}
name = (*env)->NewStringUTF(env, hostname);
if (IS_NULL(name)) {
ret = NULL;
goto cleanupAndReturn;
}
while (iterator != NULL) {
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
@ -324,7 +318,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex++;
} else if (iterator->ai_family == AF_INET6) {
@ -355,7 +349,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index++;
}

View File

@ -137,7 +137,6 @@ JNIEXPORT jobjectArray JNICALL
Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
jobject name;
struct hostent *hp;
unsigned int addr[4];
@ -229,10 +228,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
addrp++;
}
name = (*env)->NewStringUTF(env, hostname);
if (IS_NULL(name)) {
goto cleanupAndReturn;
}
ret = (*env)->NewObjectArray(env, i, ni_iacls, NULL);
if (IS_NULL(ret)) {
@ -249,7 +244,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl((*addrp)->s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, i, iaObj);
addrp++;
i++;

View File

@ -86,7 +86,6 @@ JNIEXPORT jobjectArray JNICALL
Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jstring host) {
const char *hostname;
jobject name;
jobjectArray ret = 0;
int retLen = 0;
jboolean preferIPv6Address;
@ -237,12 +236,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
inet6Index = inetCount;
}
name = (*env)->NewStringUTF(env, hostname);
if (IS_NULL(name)) {
ret = NULL;
goto cleanupAndReturn;
}
while (iterator != NULL) {
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
@ -252,7 +245,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex ++;
} else if (iterator->ai_family == AF_INET6) {
@ -276,7 +269,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
(*env)->SetObjectField(env, iaObj, ni_iahostID, name);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index ++;
}