-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed #12674
Conversation
👋 Welcome back alanb! A progress list of the required criteria for merging this PR into |
@AlanBateman The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
test/jdk/java/nio/channels/DatagramChannel/AdaptorAsyncCloseAfterReceive.java
Show resolved
Hide resolved
test/jdk/java/nio/channels/DatagramChannel/AdaptorAsyncCloseAfterReceive.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Alan for the updates. This looks good to me.
@AlanBateman This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Though we can't rule that this test will fail intermittently if it receives stray datagrams sent by other tests / processes. I wonder if the lambda passed to assertThrows should be modified to return to receive if it receives a datagram whose socket address is not null and not that of dc
.
/integrate |
Going to push as commit b6ecca1.
Your commit was automatically rebased without conflicts. |
@AlanBateman Pushed as commit b6ecca1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is an issue with the async close of a DatagramChannel when a thread is blocked in its adaptor's receive method and the underlying socket is non-blocking. The async close causes poll to wakeup and the underlying receive to return 0 so it can't be distinguished from a receive of a zero-length datagram. The channel state needs to be checked to distinguish the two cases so that AsynchronousCloseException can be thrown if the channel has been closed. The bug goes back to JDK 14 when caching of sockaddr structured was introduced.
The test case creates the conditions to exercise the case for both the timed and untimed receive. The bug report is the timed case, which receives two datagrams before attempting a timed receive. The harder case to test is the untimed case so the test uses a virtual thread to force the underlying socket to be non-blocking.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12674/head:pull/12674
$ git checkout pull/12674
Update a local copy of the PR:
$ git checkout pull/12674
$ git pull https://git.openjdk.org/jdk pull/12674/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12674
View PR using the GUI difftool:
$ git pr show -t 12674
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12674.diff