Skip to content

Calling avoidProxy with illegal URL throws NullPointerException #560

Closed
@scr

Description

@scr

Below is a patch to ProxyUtilsTest.java that shows a reduction of the issue.

Running TestSuite
Tests run: 94, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 13.271 sec <<< FAILURE! - in TestSuite
testBasics(org.asynchttpclient.util.ProxyUtilsTest)  Time elapsed: 0.013 sec  <<< FAILURE!
java.lang.NullPointerException: null
    at org.asynchttpclient.util.ProxyUtils.avoidProxy(ProxyUtils.java:116)
    at org.asynchttpclient.util.ProxyUtils.avoidProxy(ProxyUtils.java:101)
    at org.asynchttpclient.util.ProxyUtilsTest.testBasics(ProxyUtilsTest.java:52)


Results :

Failed tests: 
  ProxyUtilsTest.testBasics:52 » NullPointer

---
diff --git a/api/src/test/java/org/asynchttpclient/util/ProxyUtilsTest.java b/api/src/test/java/org/asynchttpclient/util/ProxyUtilsTest.java
index fdcb888..19db97c 100644
--- a/api/src/test/java/org/asynchttpclient/util/ProxyUtilsTest.java
+++ b/api/src/test/java/org/asynchttpclient/util/ProxyUtilsTest.java
@@ -44,5 +44,11 @@ public class ProxyUtilsTest {
         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();
+        proxyServer = new ProxyServer("foo", 1234);
+        proxyServer.addNonProxyHost("*.somewhere.org");
+        assertFalse(ProxyUtils.avoidProxy(proxyServer, req));
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions