Skip to content

Commit

Permalink
8301457: Code in SendPortZero.java is uncommented even after JDK-8236…
Browse files Browse the repository at this point in the history
…852 was fixed

Backport-of: 298dda4c985ddda84e264aff86ea45c849bb171c
  • Loading branch information
GoeLin committed Nov 1, 2023
1 parent 599b30d commit 05deef8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 13 additions & 11 deletions test/jdk/java/net/DatagramSocket/SendPortZero.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -29,6 +29,7 @@
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
Expand Down Expand Up @@ -69,37 +70,38 @@ public void setUp() throws IOException {

// Addresses
loopbackAddr = InetAddress.getLoopbackAddress();
//wildcardAddr = new InetSocketAddress(0).getAddress();
wildcardAddr = new InetSocketAddress(0).getAddress();

// Packets
// loopback w/port 0
loopbackZeroPkt = new DatagramPacket(buf, 0, buf.length);
loopbackZeroPkt.setAddress(loopbackAddr);
loopbackZeroPkt.setPort(0);

/*
//Commented until JDK-8236852 is fixed
// wildcard w/port 0
wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length);
wildcardZeroPkt.setAddress(wildcardAddr);
wildcardZeroPkt.setPort(0);

//Commented until JDK-8236807 is fixed
// wildcard addr w/valid port
// Not currently tested. See JDK-8236807
wildcardValidPkt = new DatagramPacket(buf, 0, buf.length);
var addr = socket.getAddress();
wildcardValidPkt.setAddress(addr);
wildcardValidPkt.setPort(socket.getLocalPort());
*/
wildcardValidPkt.setAddress(wildcardAddr);
wildcardValidPkt.setPort(datagramSocket.getLocalPort());
}

@DataProvider(name = "data")
public Object[][] variants() {
return new Object[][]{
{ datagramSocket, loopbackZeroPkt },
{ datagramSocket, wildcardZeroPkt },
// Re-enable when JDK-8236807 fixed
//{ datagramSocket, wildcardValidPkt },

{ datagramSocketAdaptor, loopbackZeroPkt },
{ datagramSocketAdaptor, wildcardZeroPkt },
// Re-enable when JDK-8236807 fixed
//{ datagramSocketAdaptor, wildcardValidPkt },
};
}

Expand Down
22 changes: 10 additions & 12 deletions test/jdk/java/net/MulticastSocket/SendPortZero.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -30,6 +30,7 @@
import java.net.DatagramPacket;
import java.net.MulticastSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.net.SocketPermission;
Expand Down Expand Up @@ -68,36 +69,33 @@ public void setUp() throws IOException {

// Addresses
loopbackAddr = InetAddress.getLoopbackAddress();
//wildcardAddr = new InetSocketAddress(0).getAddress();
wildcardAddr = new InetSocketAddress(0).getAddress();

// Packets
// loopback w/port 0
loopbackZeroPkt = new DatagramPacket(buf, 0, buf.length);
loopbackZeroPkt.setAddress(loopbackAddr);
loopbackZeroPkt.setPort(0);

/*
//Commented until JDK-8236852 is fixed
// wildcard w/port 0
wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length);
wildcardZeroPkt.setAddress(wildcardAddr);
wildcardZeroPkt.setPort(0);

//Commented until JDK-8236807 is fixed
// wildcard addr w/valid port
// Not currently tested. See JDK-8236807
wildcardValidPkt = new DatagramPacket(buf, 0, buf.length);
var addr = socket.getAddress();
wildcardValidPkt.setAddress(addr);
wildcardValidPkt.setPort(socket.getLocalPort());
*/
wildcardValidPkt.setAddress(wildcardAddr);
wildcardValidPkt.setPort(multicastSocket.getLocalPort());
}

@DataProvider(name = "data")
public Object[][] variants() {
return new Object[][]{
{ multicastSocket, loopbackZeroPkt }
{ multicastSocket, loopbackZeroPkt },
{ multicastSocket, wildcardZeroPkt },
// Not currently tested. See JDK-8236807
//{ multicastSocket, wildcardValidPkt }
};
}

Expand Down

1 comment on commit 05deef8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.