Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improved error messages if an invalid URL was passed #1442

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

Merged
slandelle merged 5 commits into AsyncHttpClient:master from bahrmichael:master
Jul 31, 2017
Merged

Improved error messages if an invalid URL was passed #1442

slandelle merged 5 commits into AsyncHttpClient:master from bahrmichael:master
Jul 31, 2017

Conversation

@bahrmichael
Copy link

@bahrmichael bahrmichael commented Jul 31, 2017

 @Test
 public void name() throws Exception {
 AsyncHttpClient asyncHttpClient = sut.getAsyncHttpClient();
 asyncHttpClient.prepareDelete("url");
 }

currently leads to

java.lang.NullPointerException: scheme
	at org.asynchttpclient.util.Assertions.assertNotNull(Assertions.java:23)
	at org.asynchttpclient.uri.Uri.<init>(Uri.java:64)
	at org.asynchttpclient.uri.Uri.create(Uri.java:39)
	at org.asynchttpclient.uri.Uri.create(Uri.java:32)
	at org.asynchttpclient.RequestBuilderBase.setUrl(RequestBuilderBase.java:148)
	at org.asynchttpclient.DefaultAsyncHttpClient.requestBuilder(DefaultAsyncHttpClient.java:259)
	at org.asynchttpclient.DefaultAsyncHttpClient.prepareDelete(DefaultAsyncHttpClient.java:157)

This may be confusing at first, so I changed the value passed from the Uri constructor to assertNotNull to be more descriptive.

Copy link
Contributor

Hi @bahrmichael

Thanks, but I think the current checks are perfectly valid as they currently are and the ones you would like should actually be in the create static method as they are related to the parsing result.

Could you please update your PR?

Thanks!

those new/different messages are not in the right place.
They are related to the parsing, not the constructor, so they should be thrown

Copy link
Author

I will.

@slandelle slandelle merged commit 9dc9e28 into AsyncHttpClient:master Jul 31, 2017
Copy link
Contributor

Thanks!

Copy link
Author

Thanks for reacting so fast! First open source PR merged 🎉

slandelle added a commit that referenced this pull request Jul 31, 2017
Motivation:
Following #1442, we shouldn't accept Uri with empty scheme or empty
host, such as "http://".
Modifications:
* Introduce MiscUtils#isEmpty(String)
* Throw IllegalArgumentException on empty scheme or host, with message
mentioning missing field and original url
Result:
Better control on Uri that could cause AHC to choke
Copy link
Contributor

Congrats! Hopefully more will follow and you'll get used to it ;-)

Please note the follow up in #1445

slandelle added a commit that referenced this pull request Jul 31, 2017
Motivation:
Following #1442, we shouldn't accept Uri with empty scheme or empty
host, such as "http://".
Modifications:
* Introduce MiscUtils#isEmpty(String)
* Throw IllegalArgumentException on empty scheme or host, with message
mentioning missing field and original url
Result:
Better control on Uri that could cause AHC to choke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

2.0.34

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /