square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.87k stars 9.16k forks source link

LoggingInterceptor Recipe Can Crash #1512

Closed GrahamFirst closed 9 years ago

GrahamFirst commented 9 years ago

I've experience code based on the LoggingInterceptor recipe crashing with a null pointer exception because chain.proceed() returned null (probably because the call was cancelled).

swankjesse commented 9 years ago

Strange, I didn't anticipate that chain.proceed() would ever return null. Are you using any other interceptors?

swankjesse commented 9 years ago

Nope, it's my own fault. Canceling a request can cause it to return null. Hmm.

swankjesse commented 9 years ago

We should fix Call#getResponse to throw rather than returning null when a call is canceled. That should fix the problem!