aboutsummaryrefslogtreecommitdiff
path: root/test/java/nio/channels
diff options
context:
space:
mode:
authorrobm <none@none>2012-06-08 18:23:28 +0100
committerrobm <none@none>2012-06-08 18:23:28 +0100
commit98efda6e2d7d4245e3527922c88d70cb1cc34c33 (patch)
tree4cbd70a7773e546919b55f5bac10c7097e103b0e /test/java/nio/channels
parentee2c405adefb56e7ea9d6b489415135322cce895 (diff)
7161881: (dc) DatagramChannel.bind(null) fails if IPv4 socket and running with preferIPv6Addresses=true
Reviewed-by: alanb, chegar
Diffstat (limited to 'test/java/nio/channels')
-rw-r--r--test/java/nio/channels/DatagramChannel/BindNull.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/java/nio/channels/DatagramChannel/BindNull.java b/test/java/nio/channels/DatagramChannel/BindNull.java
new file mode 100644
index 000000000..5126d41a2
--- /dev/null
+++ b/test/java/nio/channels/DatagramChannel/BindNull.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7161881
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true BindNull
+ * @summary Make sure the bind method uses an ipv4 address for the null case
+ * when the DatagramChannel is connected to an IPv4 socket and
+ * -Djava.net.preferIPv6Addresses=true.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.nio.channels.*;
+
+public class BindNull {
+ public static void main(String[] args) throws IOException {
+ try (DatagramChannel dc = DatagramChannel.open()) {
+ dc.bind(null);
+ }
+ try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
+ dc.bind(null);
+ }
+ try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
+ dc.bind(null);
+ } catch (UnsupportedOperationException uoe) {
+ // IPv6 not available
+ }
+ }
+}