aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Zhou <maxzhou@google.com>2014-02-03 09:20:20 -0800
committerMax Zhou <maxzhou@google.com>2014-02-03 09:36:57 -0800
commitc7e6423f62e5472f1a1e602c419c454ce793bd13 (patch)
treea0140150f5a585f01a510bd3cf9b0ea2bbbc4887 /src
parent3334f157874f20353d1510f8e6910b59c6a83970 (diff)
downloadvolley-c7e6423f62e5472f1a1e602c419c454ce793bd13.tar.gz
Volley to create valid NetworkResponse object when cache is disabled
* Add null check to request.CacheEntry() when creating NetworkResponse. Currently when cache is not used, rather than creating a valid NetworkResponse object, BasicNetwork.performRequest() throws NPE when processing a http 304 no modified response. The NetworkResponse object, if returned with the Volley error, can be used by the volley caller to determine the http status code. Change-Id: I007468ed98fb7ed5719a94f871323466e1bd0f8a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/volley/toolbox/BasicNetwork.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/com/android/volley/toolbox/BasicNetwork.java b/src/com/android/volley/toolbox/BasicNetwork.java
index 5883904..c82fc34 100644
--- a/src/com/android/volley/toolbox/BasicNetwork.java
+++ b/src/com/android/volley/toolbox/BasicNetwork.java
@@ -98,7 +98,8 @@ public class BasicNetwork implements Network {
// Handle cache validation.
if (statusCode == HttpStatus.SC_NOT_MODIFIED) {
return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED,
- request.getCacheEntry().data, responseHeaders, true);
+ request.getCacheEntry() == null ? null : request.getCacheEntry().data,
+ responseHeaders, true);
}
// Some responses such as 204s do not have content. We must check.