Skip to content

Check for null target in avoidProxy to prevent exceptions; Close #560. #561

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

Closed
wants to merge 2 commits into from

Conversation

scr
Copy link

@scr scr commented May 21, 2014

No description provided.

@@ -44,5 +44,11 @@ public void testBasics() {
proxyServer = new ProxyServer("foo", 1234);
proxyServer.addNonProxyHost("*.somewhere.org");
assertFalse(ProxyUtils.avoidProxy(proxyServer, req));

// shouldn't crash
req = new RequestBuilder("GET").setUrl("http:///badhost/foo").build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why shouldn't this crash?

Copy link
Author

Choose a reason for hiding this comment

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

The error is happening pretty deep in the guts of the code at the point where you already have the url and are trying to execute it (see partial stacktrace below). Ultimately, I'd be fine with dropping this change and test as long as the changes to AsyncHttpProviderUtils make it in, because then callers can check bad urls ahead of time. Would you honor the pull request if I dropped ProxyUtils*?

java.lang.NullPointerException
at com.ning.http.util.ProxyUtils.avoidProxy(ProxyUtils.java:101)
at com.ning.http.util.ProxyUtils.avoidProxy(ProxyUtils.java:86)
at com.ning.http.util.ProxyUtils.getProxyServer(ProxyUtils.java:72)
at
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:955)
at
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:937)
at
com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:520)

Copy link
Contributor

Choose a reason for hiding this comment

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

From my pov, this should crash as soon as possible, meaning in setUrl where the illegal url is passed.

slandelle pushed a commit that referenced this pull request Jun 12, 2014
@slandelle slandelle closed this in df81d44 Jun 12, 2014
slandelle pushed a commit that referenced this pull request Jun 12, 2014
cs-workco pushed a commit to cs-workco/async-http-client that referenced this pull request Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants