Commit 2435e09a authored by Ricki Hirner's avatar Ricki Hirner

Fix NPE

parent f78c1b62
Pipeline #9215127 passed with stage
in 4 minutes and 16 seconds
......@@ -14,7 +14,6 @@ buildscript {
repositories {
jcenter()
mavenCentral()
}
apply plugin: 'com.android.library'
......@@ -48,6 +47,7 @@ android {
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:support-annotations:26.+'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
......
......@@ -279,7 +279,7 @@ class BasicDigestAuthHandler(
}
override fun authenticate(route: Route, response: Response) =
override fun authenticate(route: Route?, response: Response) =
authenticateRequest(response.request(), response)
override fun intercept(chain: Interceptor.Chain): Response {
......
......@@ -258,4 +258,20 @@ public class BasicDigestAuthHandlerTest {
assertNotNull(authenticator.digestRequest(original, authScheme));
}
@Test
public void testAuthenticateNull() {
BasicDigestAuthHandler authenticator = new BasicDigestAuthHandler(null, "demo", "demo");
// must not crash (route may be null)
Request request = new Request.Builder()
.get()
.url("http://example.com")
.build();
Response response = new Response.Builder()
.request(request)
.protocol(Protocol.HTTP_2)
.code(200).message("OK")
.build();
authenticator.authenticate(null, response);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment