8217427: (dc) nio/channels/DatagramChannel/UseDGWithIPv6.java fails without IPv6

Reviewed-by: alanb, clanger
This commit is contained in:
Nick Gasson 2019-01-22 10:25:22 +08:00
parent bc651663e3
commit c0de8f27a5

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,8 @@
/* @test /* @test
* @bug 6435300 * @bug 6435300
* @summary Check using IPv6 address does not crash the VM * @summary Check using IPv6 address does not crash the VM
* @run main/othervm UseDGWithIPv6
* @run main/othervm -Djava.net.preferIPv4Stack=true UseDGWithIPv6
*/ */
import java.io.IOException; import java.io.IOException;
@ -31,6 +33,7 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel; import java.nio.channels.DatagramChannel;
import java.nio.channels.UnsupportedAddressTypeException;
public class UseDGWithIPv6 { public class UseDGWithIPv6 {
static String[] targets = { static String[] targets = {
@ -57,6 +60,8 @@ public class UseDGWithIPv6 {
try { try {
int n = dgChannel.send(data, sa); int n = dgChannel.send(data, sa);
System.out.println("DG_Sent " + n + " bytes"); System.out.println("DG_Sent " + n + " bytes");
} catch (UnsupportedAddressTypeException e) {
System.out.println("Ignoring unsupported address type");
} catch (IOException e) { } catch (IOException e) {
//This regression test is to check vm crash only, so ioe is OK. //This regression test is to check vm crash only, so ioe is OK.
e.printStackTrace(); e.printStackTrace();