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

Reviewed-by: aefimov, msheppar
  • Loading branch information
Michael-Mc-Mahon committed Jul 24, 2023
1 parent 7dd4799 commit 298dda4
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

3 comments on commit 298dda4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 298dda4 Oct 31, 2023

Choose a reason for hiding this comment

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

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 298dda4 Oct 31, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-298dda4c in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 298dda4c from the openjdk/jdk repository.

The commit being backported was authored by Michael McMahon on 24 Jul 2023 and was reviewed by Aleksei Efimov and Mark Sheppard.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git GoeLin-backport-298dda4c:GoeLin-backport-298dda4c
$ git checkout GoeLin-backport-298dda4c
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git GoeLin-backport-298dda4c

Please sign in to comment.