Skip to content

Commit 05deef8

Browse files
committedNov 1, 2023
8301457: Code in SendPortZero.java is uncommented even after JDK-8236852 was fixed
Backport-of: 298dda4c985ddda84e264aff86ea45c849bb171c
1 parent 599b30d commit 05deef8

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed
 

‎test/jdk/java/net/DatagramSocket/SendPortZero.java

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
2929
import java.io.IOException;
3030
import java.net.DatagramPacket;
3131
import java.net.DatagramSocket;
32+
import java.net.InetSocketAddress;
3233
import java.net.InetAddress;
3334
import java.net.MulticastSocket;
3435
import java.net.SocketException;
@@ -69,37 +70,38 @@ public void setUp() throws IOException {
6970

7071
// Addresses
7172
loopbackAddr = InetAddress.getLoopbackAddress();
72-
//wildcardAddr = new InetSocketAddress(0).getAddress();
73+
wildcardAddr = new InetSocketAddress(0).getAddress();
7374

7475
// Packets
7576
// loopback w/port 0
7677
loopbackZeroPkt = new DatagramPacket(buf, 0, buf.length);
7778
loopbackZeroPkt.setAddress(loopbackAddr);
7879
loopbackZeroPkt.setPort(0);
7980

80-
/*
81-
//Commented until JDK-8236852 is fixed
82-
8381
// wildcard w/port 0
8482
wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length);
8583
wildcardZeroPkt.setAddress(wildcardAddr);
8684
wildcardZeroPkt.setPort(0);
8785

88-
//Commented until JDK-8236807 is fixed
89-
9086
// wildcard addr w/valid port
87+
// Not currently tested. See JDK-8236807
9188
wildcardValidPkt = new DatagramPacket(buf, 0, buf.length);
92-
var addr = socket.getAddress();
93-
wildcardValidPkt.setAddress(addr);
94-
wildcardValidPkt.setPort(socket.getLocalPort());
95-
*/
89+
wildcardValidPkt.setAddress(wildcardAddr);
90+
wildcardValidPkt.setPort(datagramSocket.getLocalPort());
9691
}
9792

9893
@DataProvider(name = "data")
9994
public Object[][] variants() {
10095
return new Object[][]{
10196
{ datagramSocket, loopbackZeroPkt },
97+
{ datagramSocket, wildcardZeroPkt },
98+
// Re-enable when JDK-8236807 fixed
99+
//{ datagramSocket, wildcardValidPkt },
100+
102101
{ datagramSocketAdaptor, loopbackZeroPkt },
102+
{ datagramSocketAdaptor, wildcardZeroPkt },
103+
// Re-enable when JDK-8236807 fixed
104+
//{ datagramSocketAdaptor, wildcardValidPkt },
103105
};
104106
}
105107

‎test/jdk/java/net/MulticastSocket/SendPortZero.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
import java.net.DatagramPacket;
3131
import java.net.MulticastSocket;
3232
import java.net.InetAddress;
33+
import java.net.InetSocketAddress;
3334
import java.net.MulticastSocket;
3435
import java.net.SocketException;
3536
import java.net.SocketPermission;
@@ -68,36 +69,33 @@ public void setUp() throws IOException {
6869

6970
// Addresses
7071
loopbackAddr = InetAddress.getLoopbackAddress();
71-
//wildcardAddr = new InetSocketAddress(0).getAddress();
72+
wildcardAddr = new InetSocketAddress(0).getAddress();
7273

7374
// Packets
7475
// loopback w/port 0
7576
loopbackZeroPkt = new DatagramPacket(buf, 0, buf.length);
7677
loopbackZeroPkt.setAddress(loopbackAddr);
7778
loopbackZeroPkt.setPort(0);
7879

79-
/*
80-
//Commented until JDK-8236852 is fixed
81-
8280
// wildcard w/port 0
8381
wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length);
8482
wildcardZeroPkt.setAddress(wildcardAddr);
8583
wildcardZeroPkt.setPort(0);
8684

87-
//Commented until JDK-8236807 is fixed
88-
8985
// wildcard addr w/valid port
86+
// Not currently tested. See JDK-8236807
9087
wildcardValidPkt = new DatagramPacket(buf, 0, buf.length);
91-
var addr = socket.getAddress();
92-
wildcardValidPkt.setAddress(addr);
93-
wildcardValidPkt.setPort(socket.getLocalPort());
94-
*/
88+
wildcardValidPkt.setAddress(wildcardAddr);
89+
wildcardValidPkt.setPort(multicastSocket.getLocalPort());
9590
}
9691

9792
@DataProvider(name = "data")
9893
public Object[][] variants() {
9994
return new Object[][]{
100-
{ multicastSocket, loopbackZeroPkt }
95+
{ multicastSocket, loopbackZeroPkt },
96+
{ multicastSocket, wildcardZeroPkt },
97+
// Not currently tested. See JDK-8236807
98+
//{ multicastSocket, wildcardValidPkt }
10199
};
102100
}
103101

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Nov 1, 2023

@openjdk-notifier[bot]
Please sign in to comment.