Skip to content

8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL#10609

Closed
dfuch wants to merge 12 commits intoopenjdk:masterfrom
dfuch:url-iae-8294948
Closed

8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL#10609
dfuch wants to merge 12 commits intoopenjdk:masterfrom
dfuch:url-iae-8294948

Conversation

@dfuch
Copy link
Member

@dfuch dfuch commented Oct 7, 2022

During the review of JDK-8293590, it was noted that some methods in URLStreamHandler were missing an @throws IllegalArgumentException clause in their API documentation.

This change adds the requested information, and also clarifies throwing MalformedURLException from URL constructors.

The CSR can be reviewed here: https://bugs.openjdk.org/browse/JDK-8294984


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-8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL
  • JDK-8294984: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10609

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 7, 2022

👋 Welcome back dfuchs! 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.

@dfuch
Copy link
Member Author

dfuch commented Oct 7, 2022

/csr needed

@openjdk openjdk bot changed the title 8294948 8294948: Document IllegalArgumetException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL Oct 7, 2022
@openjdk openjdk bot added rfr Pull request is ready for review csr Pull request needs approved CSR before integration labels Oct 7, 2022
@openjdk
Copy link

openjdk bot commented Oct 7, 2022

@dfuch this pull request will not be integrated until the CSR request JDK-8294984 for issue JDK-8294948 has been approved.

@openjdk
Copy link

openjdk bot commented Oct 7, 2022

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

  • net

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 net net-dev@openjdk.org label Oct 7, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 7, 2022

@dfuch dfuch changed the title 8294948: Document IllegalArgumetException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL 8294948: Document IllegalArgumetException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL Oct 7, 2022
@dfuch dfuch changed the title 8294948: Document IllegalArgumetException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL 8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL Oct 10, 2022
@jaikiran
Copy link
Member

Hello Daniel, the change looks fine to me and it does indeed document what is already being thrown from those methods currently.

Copy link
Member

@AlekseiEfimov AlekseiEfimov left a comment

Choose a reason for hiding this comment

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

New documentation looks good to me, and matches the source code.

* URLStreamHandler#parseURL(URL, String, int, int) parseURL method} is
* called during URL construction and it throws {@code IllegalArgumentException}.
* However, which checks are performed is implementation dependent, and
* callers should not rely on such checks for full URL validation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the API note will need a few adjustments.

The first sentence uses the word "additionally" but the text prior to that isn't about throwing exceptions. I think what you mean is in addition to the reasons specified by the URL constructors, in which case this makes it normative. Maybe you could lend on the text "parsed URL fails to comply ..." or if that is too complicated then just drop this part of the API note.

A second sentence uses "In particular when ..." but I don't think URL specifies that it calls the parseURL method. If the URL constructors did specify this when you could reference it here. If you map to document the mapping of ISE to MalformedURLException then I think the URL constructors will need to document that they delegate to parseURL and throw MalformedURLException if the parsing fails with IAE.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @AlanBateman - I have updated the API note, added an @implSpec in two of the constructors to spell out that they are calling the stream handler's parseURL method (the first one says it's equivalent to the second one so I don't think @implSpec is needed there), and improved the @throws MalformedURLException with more details.
Does the new text match your expectations?

*
* @implSpec Parsing the URL involves calling the {@link
* URLStreamHandler#parseURL(URL, String, int, int) parseURL} method on the
* selected handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

What you would think about making this more direct, e.g. "This constructor invokes the selected stream handler's parseURL method to parse the URL."

Copy link
Member Author

Choose a reason for hiding this comment

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

Well some of the parsing is done in URL itself: like finding the fragment, if any, setting up start and limit etc... And I didn't want to get into the rabbit hole of trying to specify what does what exactly. I can still take your suggested text if you believe it doesn't matter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, maybe your wording would be be okay if you changed "involves" to "includes" as the former hints that there is more going on that is not specified.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! Will do.

* of the associated protocol. In particular, if the
* underlying stream handler's {@linkplain
* URLStreamHandler#parseURL parseURL method} throws
* {@code IllegalArgumentException}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks okay but it might be simpler to drop "In particular" and just say "or the stream handler's parseURL throws ...".

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @AlanBateman I have pushed all the requested changes and updated the CSR. If that looks good to you I will finalize the CSR.

Copy link
Member

@Michael-Mc-Mahon Michael-Mc-Mahon left a comment

Choose a reason for hiding this comment

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

LGTM

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

openjdk bot commented Oct 19, 2022

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

8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL

Reviewed-by: jpai, aefimov, alanb, michaelm

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

  • f872467: 8255746: Make PrintCompilation available on a per method level
  • 388a56e: 8294467: Fix sequence-point warnings in Hotspot
  • ceb5b08: 8294468: Fix char-subscripts warnings in Hotspot
  • 7b1c676: 8295662: jdk/incubator/vector tests fail "assert(VM_Version::supports_avx512vlbw()) failed"
  • 5eaf568: 8295668: validate-source failure after JDK-8290011
  • e238920: 8295372: CompactNumberFormat handling of number one with decimal part
  • a5f6e31: 8295456: (ch) sun.nio.ch.Util::checkBufferPositionAligned gives misleading/incorrect error
  • e27bea0: 8290011: IGV: Remove dead code and cleanup
  • d37ce4c: 8290368: Introduce LDAP and RMI protocol-specific object factory filters to JNDI implementation

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 19, 2022
@dfuch
Copy link
Member Author

dfuch commented Oct 20, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Oct 20, 2022

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

  • dcd4650: 8294916: Cancelling a request must eventually cause its response body subscriber to be unregistered
  • 4f994c0: 8295709: Linux AArch64 builds broken after JDK-8294438
  • 545021b: 8294438: Fix misleading-indentation warnings in hotspot
  • c5e0464: 8291456: com/sun/jdi/ClassUnloadEventTest.java failed with: Wrong number of class unload events: expected 10 got 4
  • 8d4c077: 8295302: Do not use ArrayList when LambdaForm has a single ClassData
  • 017e798: 8293939: Move continuation_enter_setup and friends
  • f872467: 8255746: Make PrintCompilation available on a per method level
  • 388a56e: 8294467: Fix sequence-point warnings in Hotspot
  • ceb5b08: 8294468: Fix char-subscripts warnings in Hotspot
  • 7b1c676: 8295662: jdk/incubator/vector tests fail "assert(VM_Version::supports_avx512vlbw()) failed"
  • ... and 5 more: https://git.openjdk.org/jdk/compare/21aeb9e7946fc7450ee48939944a69c8aa04bcce...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 20, 2022

@dfuch Pushed as commit 9d0cfd1.

💡 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

integrated Pull request has been integrated net net-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants