Skip to content
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

8290353: ModuleReader::list specification should suggest closing the returned stream #9538

Closed
wants to merge 7 commits into from

Conversation

rjernst
Copy link
Contributor

@rjernst rjernst commented Jul 18, 2022

This commit adds additional clarification to the javadocs of
ModuleReader::list about needing to close the stream. The new wording is
similar to that used in Files::find and other similar methods.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires a CSR request to be approved

Issues

  • JDK-8290353: ModuleReader::list specification should suggest closing the returned stream
  • JDK-8290521: ModuleReader::list specification should suggest closing the returned stream (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9538/head:pull/9538
$ git checkout pull/9538

Update a local copy of the PR:
$ git checkout pull/9538
$ git pull https://git.openjdk.org/jdk pull/9538/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9538

View PR using the GUI difftool:
$ git pr show -t 9538

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9538.diff

This commit adds additional clarification to the javadocs of
ModuleReader::list about needing to close the stream. The new wording is
similar to that used in Files::find and other similar methods.
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 18, 2022

👋 Welcome back rjernst! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 18, 2022
@openjdk
Copy link

openjdk bot commented Jul 18, 2022

@rjernst The following label will be automatically applied to this pull request:

  • core-libs

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.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jul 18, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 18, 2022

Webrevs

@@ -213,9 +213,17 @@ default void release(ByteBuffer bb) {
* when using the stream to list the module contents and access is denied
* by the security manager. </p>
*
* <p> The returned stream contains references to one or more open directories
* in the module. The directories are closed by closing the stream. </p>
Copy link
Member

Choose a reason for hiding this comment

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

This mostly looks good - I agree with adding the note here. Should the wording be relaxed a little - replace "contains references" with "may contain references" - since the stream will not always contain references to open directories - it depends on the type of reader. The end result / guidance is the same - use in a try-with-resources block - I'm just suggesting a slight relaxing of the wording.

Copy link
Member

Choose a reason for hiding this comment

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

"may contain references" is good. I agree that the wordings should be relaxed a little. Similar for the apiNote.

* <p> The behavior of the stream when used after the module reader is
* closed is implementation specific and therefore not specified. </p>
*
* @apiNote
* This method must be used within a try-with-resources statement or similar
* control structure to ensure that the stream's open directories are closed
Copy link
Member

Choose a reason for hiding this comment

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

Similar to my other comment - should "must' be replaced with "should" - for the same aforementioned reason.

@ChrisHegarty
Copy link
Member

ChrisHegarty commented Jul 18, 2022

Given the recommendation to close streams returned by the list method, then this PR could be extended to update any usages in, at least, java.base. If there are many usages beyond java.base, then a separate issue could be filed to update them too. ( if not already covered by a previous PR in this area )

@rjernst
Copy link
Contributor Author

rjernst commented Jul 18, 2022

I relaxed the wording in 0b3ca18 and addressed uses of list() in java.base in a72a5b9.

@mbreinhold
Copy link
Member

It’s odd to mix adding some advice to the Javadoc with adopting that advice in the code base. Consider opening a new issue and PR for the actual code changes.

Also, a better summary for this issue (and PR) would be “ModuleReader::list specification should suggest closing the returned stream,” since that’s the essence of it.

@ChrisHegarty
Copy link
Member

It’s odd to mix adding some advice to the Javadoc with adopting that advice in the code base. Consider opening a new issue and PR for the actual code changes.

JDK-8290504 has been filed to track the implementation changes. @rjernst please separate out the implementation changes into a separate PR, using 8290504 as the linked JIRA issue. (apologies, I previously asked for the implementation changes to be in this PR )

Also, a better summary for this issue (and PR) would be “ModuleReader::list specification should suggest closing the returned stream,” since that’s the essence of it.

Agreed. I updated the JIRA issue summary as suggested. @rjernst please update the title of this PR to match.

@ChrisHegarty
Copy link
Member

/csr

@ChrisHegarty
Copy link
Member

The following CSR has been filed for this issue, https://bugs.openjdk.org/browse/JDK-8290521. Please review.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jul 19, 2022
@openjdk
Copy link

openjdk bot commented Jul 19, 2022

@ChrisHegarty this pull request will not be integrated until the CSR request JDK-8290521 for issue JDK-8290353 has been approved.

@rjernst rjernst changed the title 8290353: Clarify the streams returned by ModuleReader::list 8290353: ModuleReader::list specification should suggest closing the returned stream Jul 19, 2022
Copy link
Member

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM

@mlchung
Copy link
Member

mlchung commented Jul 19, 2022

Looks good to me. I reviewed the CSR.

Copy link
Member

@mbreinhold mbreinhold left a comment

Choose a reason for hiding this comment

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

Ship it!

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jul 20, 2022
@openjdk
Copy link

openjdk bot commented Jul 20, 2022

@rjernst 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:

8290353: ModuleReader::list specification should suggest closing the returned stream

Reviewed-by: chegar, mchung, mr, jpai

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 14 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@ChrisHegarty, @mlchung, @mbreinhold, @jaikiran) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 20, 2022
@jaikiran
Copy link
Member

Hello Ryan, the change looks fine to me. Please update the copyright year on the ModuleReader.java file, from 2020 to 2022.

@rjernst
Copy link
Contributor Author

rjernst commented Jul 20, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 20, 2022
@openjdk
Copy link

openjdk bot commented Jul 20, 2022

@rjernst
Your change (at version 58ac453) is now ready to be sponsored by a Committer.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

Thank you Ryan for the copyright change. Looks fine to me.

@ChrisHegarty
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 21, 2022

Going to push as commit db1e44c.
Since your change was applied there have been 15 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 21, 2022
@openjdk openjdk bot closed this Jul 21, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jul 21, 2022
@openjdk
Copy link

openjdk bot commented Jul 21, 2022

@ChrisHegarty @rjernst Pushed as commit db1e44c.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants