提交 bfd3c08d 编写于 作者: C chegar

8071424: JCK test api/java_net/Socket/descriptions.html#Bind crashes on Windows

Reviewed-by: alanb
上级 16e06f85
...@@ -48,6 +48,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_initIDs ...@@ -48,6 +48,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_initIDs
isa_ctorID = (*env)->GetMethodID(env, cls, "<init>", isa_ctorID = (*env)->GetMethodID(env, cls, "<init>",
"(Ljava/net/InetAddress;I)V"); "(Ljava/net/InetAddress;I)V");
CHECK_NULL(isa_ctorID); CHECK_NULL(isa_ctorID);
initInetAddressIDs(env);
// implement read timeout with select. // implement read timeout with select.
isRcvTimeoutSupported = 0; isRcvTimeoutSupported = 0;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4106601 8026245 * @bug 4106601 8026245 8071424
* @run main/othervm GetLocalAddress * @run main/othervm GetLocalAddress
* @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalAddress * @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalAddress
* @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalAddress * @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalAddress
...@@ -39,6 +39,8 @@ public class GetLocalAddress implements Runnable { ...@@ -39,6 +39,8 @@ public class GetLocalAddress implements Runnable {
static int port; static int port;
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
testBindNull();
boolean error = true; boolean error = true;
int linger = 65546; int linger = 65546;
int value = 0; int value = 0;
...@@ -66,4 +68,19 @@ public class GetLocalAddress implements Runnable { ...@@ -66,4 +68,19 @@ public class GetLocalAddress implements Runnable {
} }
} }
static void testBindNull() throws Exception {
try (Socket soc = new Socket()) {
soc.bind(null);
if (!soc.isBound())
throw new RuntimeException(
"should be bound after bind(null)");
if (soc.getLocalPort() <= 0)
throw new RuntimeException(
"bind(null) failed, local port: " + soc.getLocalPort());
if (soc.getLocalAddress() == null)
throw new RuntimeException(
"bind(null) failed, local address is null");
}
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册