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

GenericUrl: improve the error message for malformed URLs #1486

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alb-i986
Copy link

Let's say by mistake we pass a malformed URL to the constructor of GenericUrl.

new GenericUrl("http://example.com:8080http://example.com:8080");

Previously the line above used to throw the following exception:

java.lang.IllegalArgumentException: java.net.MalformedURLException: Error at index 4 in: "8080http:"

Not very helpful.

Whereas with this patch:

java.lang.IllegalArgumentException: Malformed URL: "http://example.com:8080http://example.com:8080/"

The exception thrown now clearly shows what was the faulty URL.
The user can therefore quickly figure out which URL needs to be fixed.

A lesson I learned today :)

The exception thrown now clearly shows which was the faulty URL.
@alb-i986 alb-i986 requested a review from a team as a code owner October 18, 2021 23:11
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 18, 2021
@eaball35 eaball35 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 21, 2022
@meltsufin meltsufin added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 14, 2023
Copy link
Member

@meltsufin meltsufin left a comment

Choose a reason for hiding this comment

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

There might be a risk of leaking sensitive data from the URL. So, I'm leaning towards the JDK deciding what the message should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. kokoro:force-run Add this label to force Kokoro to re-run the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants