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
JDK-8297605 DelayQueue javadoc is confusing #12729
Conversation
Updated version of #12727 |
👋 Welcome back viktorklang-ora! A progress list of the required criteria for merging this PR into |
@viktorklang-ora 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
|
Thanks. Adding the word "expired" (plus other adjustments) seems to be the simplest way to avoid confusion. |
@@ -51,8 +51,7 @@ | |||
* {@code Delayed} elements, in which an element can only be taken | |||
* when its delay has expired. The <em>head</em> of the queue is that | |||
* {@code Delayed} element whose delay expired furthest in the | |||
* past. If no delay has expired there is no head and {@code poll} |
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.
I like introducing the concept of "expired head".
Aren't we defining "expired head" here, not "head"?
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.
@Martin-Buchholz I read the line before the removed line (The head of the queue is that {@code Delayed} element whose delay expired furthest in the past.) as defining that the head will be the thing with the "soonest" expiry, which is important if one is used to LIFO or FIFO. Any idea on how we could improve that sentence? 🤔
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.
I like extending this approach as follows:
- define "head"
- define "expired head"
- make it clear that some methods operate on all elements (regardless of their expiration status), some only on expired elements.
- ensure that all public methods have an overriding javadoc that makes the distinction clear. e.g. currently remove() needs such an overriding javadoc.
(writing good spec is hard work!)
Here's my attempt:
|
6ef8291
to
df54e8a
Compare
@viktorklang-ora Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
I think that approach sounds good. @DougLea, any opinion on this class javadoc summary? |
Yes, lgtm! |
@Martin-Buchholz Martin, how would you like to proceed with your proposed wording, would you prefer a suggested edit to this PR, do a separate PR, or otherwise? /cc @AlanBateman (any recommendation, Alan? 🤔 ) |
Talked me into it - I will dust off my github/skara skillz and make a new PR. I wonder if there's now a way to override javadoc for remove() without creating a new method body. |
@Martin-Buchholz I guess |
I thought recent javadoc features might have been useful here, but I scanned the results from this jql:
and came up empty |
Perhaps @pavelrappo has any suggestion for adding clarifying Javadoc to a subclass without having to override the method? 🤔 |
You cannot do that. |
@Martin-Buchholz @pavelrappo OTOH I see that DelayQueue has already overridden |
Right. But remove(Object) unlike remove() doesn't consider the expiration time. Confusing! |
Actually, confusion extends to three methods with the same name:
|
@Martin-Buchholz Oh that remove() :) |
@viktorklang-ora this pull request can not be integrated into git checkout 8297605
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
Superseded by #12838 |
Clarifies the distinction between expiration of the head of DelayQueue and how it relates to
poll
,take
, andpeek
. See discussion on https://bugs.openjdk.org/browse/JDK-8297605@DougLea If possible, please weigh in on whether this is in line with your thoughts on the matter.
Progress
Integration blocker
Issues
Backport <hash>
with the hash of the original commit. See Backports.Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/12729/head:pull/12729
$ git checkout pull/12729
Update a local copy of the PR:
$ git checkout pull/12729
$ git pull https://git.openjdk.org/jdk.git pull/12729/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12729
View PR using the GUI difftool:
$ git pr show -t 12729
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12729.diff