Skip to content

Commit de5d7d2

Browse files
author
Jesse Wilson
committed
Test to demonstrate NPE in DefaultRequestDirector
When the HTTP client encountered a server failure while talking through a proxy, it fails with an NullPointerException and not an IOException. Change-Id: I4b287105bf78b832d034557e37e74ce576c7894d Bug: http://b/5372438
1 parent cbb62bb commit de5d7d2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

core/tests/coretests/src/android/net/http/AbstractProxyTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ public void testExplicitNoProxyCancelsSystemProperty() throws Exception {
219219
assertEquals("GET /bar HTTP/1.1", recordedRequest.getRequestLine());
220220
}
221221

222+
// http://b/5372438
223+
public void testRetryWithProxy() throws Exception {
224+
server.enqueue(new MockResponse()
225+
.setSocketPolicy(SocketPolicy.DISCONNECT_AT_START));
226+
server.play();
227+
228+
HttpClient httpProxyClient = newHttpClient();
229+
HttpGet request = new HttpGet("http://android.com/foo");
230+
ProxyConfig.REQUEST_PARAMETER.configure(server, httpProxyClient, request);
231+
232+
try {
233+
httpProxyClient.execute(request);
234+
fail();
235+
} catch (IOException expected) {
236+
}
237+
}
238+
222239
enum ProxyConfig {
223240
PROXY_SYSTEM_PROPERTY() {
224241
@Override void configure(MockWebServer server, HttpClient client, HttpRequest request) {

0 commit comments

Comments
 (0)