Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Update NetworkDispatcher.java #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main/java/com/android/volley/NetworkDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ private void addTrafficStatsTag(Request<?> request) {
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
Request<?> request;
NetworkResponse networkResponse;
Response<?> response;
while (true) {
long startTimeMs = SystemClock.elapsedRealtime();
// release previous request object to avoid leaking request object when mQueue is drained.
// release previous tmp objects to avoid leaking these objects when mQueue is drained.
request = null;
networkResponse = null;
response = null;
try {
// Take a request from the queue.
request = mQueue.take();
Expand All @@ -111,7 +115,7 @@ public void run() {
addTrafficStatsTag(request);

// Perform the network request.
NetworkResponse networkResponse = mNetwork.performRequest(request);
networkResponse = mNetwork.performRequest(request);
request.addMarker("network-http-complete");

// If the server returned 304 AND we delivered a response already,
Expand All @@ -122,7 +126,7 @@ public void run() {
}

// Parse the response here on the worker thread.
Response<?> response = request.parseNetworkResponse(networkResponse);
response = request.parseNetworkResponse(networkResponse);
request.addMarker("network-parse-complete");

// Write to cache if applicable.
Expand Down