aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/Request.java
diff options
context:
space:
mode:
authorAnonymous <no-reply@google.com>2018-05-07 11:39:31 -0700
committerJeff Davidson <jpd@google.com>2018-05-10 20:11:47 +0000
commit9a128540048414c78a2be9524f93b6234c640b3a (patch)
treef39fa51c442a9c6922d1f6def2e75d5dca677f20 /src/main/java/com/android/volley/Request.java
parentaee0d184daa41c0abb5bf88580ad6cf7fea63d72 (diff)
downloadvolley-9a128540048414c78a2be9524f93b6234c640b3a.tar.gz
Import of Volley from GitHub to AOSP.android-o-mr1-iot-release-1.0.1
Adds android-support-annotations as a runtime dependency in Android.mk. - 28588322fa4eca3c1a7922b8a2f7b4a97d5c099a Fix concurrent modification errors in ImageContainer. (#1... by Jeff Davidson <jpd236@cornell.edu> - ba3b40457a97b3b3812cb00191b41cb0af4149df Fix unchecked operations in Volley build. (#178) by Jeff Davidson <jpd236@cornell.edu> - 62c19019e43a76ba4a084b25548e7fb1cfd4a457 Always close HttpURLConnections in HurlStack. (#176) by Jeff Davidson <jpd236@cornell.edu> - 36c80f25a78cf2ba2feb2d697f12f9bbca96bf43 Port dispatcher tests to mockito. (#172) by Jeff Davidson <jpd236@cornell.edu> - 15b55093fc8ac86902a745f46a2bdea825e797a3 Cleaning up parameter comments + unnecessary generics. (#... by Jeff Davidson <jpd236@cornell.edu> - 6b341755e522f23de149544536b9b69c7b7b8305 Remove all wildcard imports. (#170) by Jeff Davidson <jpd236@cornell.edu> - a8424005b3ba6d17fc9e123a2176da702f3ead10 Use actual annotations instead of comments. (#169) by Jeff Davidson <jpd236@cornell.edu> - bdc80555aee738235bd33c26878bbe8ce382d795 Apply google-java-format to all code. (#165) by Jeff Davidson <jpd236@cornell.edu> - 5307293b15dd0c32f53b8f1fd8c198caa443982e Integrate Volley builds with errorprone. (#162) by Jeff Davidson <jpd236@cornell.edu> - fa586029500e6813d654f1b454cd3345b0a43897 Fail Travis builds if snapshot uploading fails. (#163) by Jeff Davidson <jpd236@cornell.edu> - 0ebb97e9b0192e879088b38b5992158e99364dc6 Stop publishing bintray-info.json. (#141) by Jeff Davidson <jpd236@cornell.edu> - b89dfbd2e6964acfe5561e268300611a83957a15 fix: request time contains RequestQueue blocking time. (#... by dezng <dezng123@gmail.com> - c2bfd86596e588c924c2c7e0ae0940053800af5c Guard against illegal argument and OOM exceptions in read... by Joe Bowbeer <joe.bowbeer@gmail.com> - fc8ff0423fe9a3af6595088b34f912fb2d920ffb Log fix (#112) by Navid Ht <navid.htb@gmail.com> - 47586f0fd42acd5ce09dfc767387df685edfa547 Bump version to 1.1.1-SNAPSHOT. (#123) by Jeff Davidson <jpd236@cornell.edu> - 1392f961af17d0f5ba367d8d199a18e5325b882e Update deploy credentials. (#122) by Jeff Davidson <jpd236@cornell.edu> - ffe9281709f38f84492ce898603d3ec084326a57 Set project group and version. (#120) by Jeff Davidson <jpd236@cornell.edu> GitOrigin-RevId: 28588322fa4eca3c1a7922b8a2f7b4a97d5c099a Change-Id: Ifeea069df2f0a5fd10bc3d4686601c88906ee653
Diffstat (limited to 'src/main/java/com/android/volley/Request.java')
-rw-r--r--src/main/java/com/android/volley/Request.java279
1 files changed, 124 insertions, 155 deletions
diff --git a/src/main/java/com/android/volley/Request.java b/src/main/java/com/android/volley/Request.java
index 358a327..c958088 100644
--- a/src/main/java/com/android/volley/Request.java
+++ b/src/main/java/com/android/volley/Request.java
@@ -20,10 +20,10 @@ import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
+import android.support.annotation.CallSuper;
+import android.support.annotation.GuardedBy;
import android.text.TextUtils;
-
import com.android.volley.VolleyLog.MarkerLog;
-
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
@@ -36,14 +36,10 @@ import java.util.Map;
*/
public abstract class Request<T> implements Comparable<Request<T>> {
- /**
- * Default encoding for POST or PUT parameters. See {@link #getParamsEncoding()}.
- */
+ /** Default encoding for POST or PUT parameters. See {@link #getParamsEncoding()}. */
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
- /**
- * Supported request methods.
- */
+ /** Supported request methods. */
public interface Method {
int DEPRECATED_GET_OR_POST = -1;
int GET = 0;
@@ -56,9 +52,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
int PATCH = 7;
}
- /**
- * Callback to notify when the network request returns.
- */
+ /** Callback to notify when the network request returns. */
/* package */ interface NetworkRequestCompleteListener {
/** Callback when a network response has been received. */
@@ -72,7 +66,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null;
/**
- * Request method of this request. Currently supports GET, POST, PUT, DELETE, HEAD, OPTIONS,
+ * Request method of this request. Currently supports GET, POST, PUT, DELETE, HEAD, OPTIONS,
* TRACE, and PATCH.
*/
private final int mMethod;
@@ -87,7 +81,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
private final Object mLock = new Object();
/** Listener interface for errors. */
- // @GuardedBy("mLock")
+ @GuardedBy("mLock")
private Response.ErrorListener mErrorListener;
/** Sequence number of this request, used to enforce FIFO ordering. */
@@ -100,11 +94,11 @@ public abstract class Request<T> implements Comparable<Request<T>> {
private boolean mShouldCache = true;
/** Whether or not this request has been canceled. */
- // @GuardedBy("mLock")
+ @GuardedBy("mLock")
private boolean mCanceled = false;
/** Whether or not a response has been delivered for this request yet. */
- // @GuardedBy("mLock")
+ @GuardedBy("mLock")
private boolean mResponseDelivered = false;
/** Whether the request should be retried in the event of an HTTP 5xx (server) error. */
@@ -114,9 +108,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
private RetryPolicy mRetryPolicy;
/**
- * When a request can be retrieved from cache but must be refreshed from
- * the network, the cache entry will be stored here so that in the event of
- * a "Not Modified" response, we can be sure it hasn't been evicted from cache.
+ * When a request can be retrieved from cache but must be refreshed from the network, the cache
+ * entry will be stored here so that in the event of a "Not Modified" response, we can be sure
+ * it hasn't been evicted from cache.
*/
private Cache.Entry mCacheEntry = null;
@@ -124,14 +118,13 @@ public abstract class Request<T> implements Comparable<Request<T>> {
private Object mTag;
/** Listener that will be notified when a response has been delivered. */
- // @GuardedBy("mLock")
+ @GuardedBy("mLock")
private NetworkRequestCompleteListener mRequestCompleteListener;
/**
- * Creates a new request with the given URL and error listener. Note that
- * the normal response listener is not provided here as delivery of responses
- * is provided by subclasses, who have a better idea of how to deliver an
- * already-parsed response.
+ * Creates a new request with the given URL and error listener. Note that the normal response
+ * listener is not provided here as delivery of responses is provided by subclasses, who have a
+ * better idea of how to deliver an already-parsed response.
*
* @deprecated Use {@link #Request(int, String, com.android.volley.Response.ErrorListener)}.
*/
@@ -141,10 +134,10 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Creates a new request with the given method (one of the values from {@link Method}),
- * URL, and error listener. Note that the normal response listener is not provided here as
- * delivery of responses is provided by subclasses, who have a better idea of how to deliver
- * an already-parsed response.
+ * Creates a new request with the given method (one of the values from {@link Method}), URL, and
+ * error listener. Note that the normal response listener is not provided here as delivery of
+ * responses is provided by subclasses, who have a better idea of how to deliver an
+ * already-parsed response.
*/
public Request(int method, String url, Response.ErrorListener listener) {
mMethod = method;
@@ -155,16 +148,14 @@ public abstract class Request<T> implements Comparable<Request<T>> {
mDefaultTrafficStatsTag = findDefaultTrafficStatsTag(url);
}
- /**
- * Return the method for this request. Can be one of the values in {@link Method}.
- */
+ /** Return the method for this request. Can be one of the values in {@link Method}. */
public int getMethod() {
return mMethod;
}
/**
- * Set a tag on this request. Can be used to cancel all requests with this
- * tag by {@link RequestQueue#cancelAll(Object)}.
+ * Set a tag on this request. Can be used to cancel all requests with this tag by {@link
+ * RequestQueue#cancelAll(Object)}.
*
* @return This Request object to allow for chaining.
*/
@@ -175,29 +166,26 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Returns this request's tag.
+ *
* @see Request#setTag(Object)
*/
public Object getTag() {
return mTag;
}
- /**
- * @return this request's {@link com.android.volley.Response.ErrorListener}.
- */
+ /** @return this request's {@link com.android.volley.Response.ErrorListener}. */
public Response.ErrorListener getErrorListener() {
- return mErrorListener;
+ synchronized (mLock) {
+ return mErrorListener;
+ }
}
- /**
- * @return A tag for use with {@link TrafficStats#setThreadStatsTag(int)}
- */
+ /** @return A tag for use with {@link TrafficStats#setThreadStatsTag(int)} */
public int getTrafficStatsTag() {
return mDefaultTrafficStatsTag;
}
- /**
- * @return The hashcode of the URL's host component, or 0 if there is none.
- */
+ /** @return The hashcode of the URL's host component, or 0 if there is none. */
private static int findDefaultTrafficStatsTag(String url) {
if (!TextUtils.isEmpty(url)) {
Uri uri = Uri.parse(url);
@@ -221,9 +209,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return this;
}
- /**
- * Adds an event to this request's event log; for debugging.
- */
+ /** Adds an event to this request's event log; for debugging. */
public void addMarker(String tag) {
if (MarkerLog.ENABLED) {
mEventLog.add(tag, Thread.currentThread().getId());
@@ -233,7 +219,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Notifies the request queue that this request has finished (successfully or with error).
*
- * <p>Also dumps all events from this request's event log; for debugging.</p>
+ * <p>Also dumps all events from this request's event log; for debugging.
*/
void finish(final String tag) {
if (mRequestQueue != null) {
@@ -245,13 +231,14 @@ public abstract class Request<T> implements Comparable<Request<T>> {
// If we finish marking off of the main thread, we need to
// actually do it on the main thread to ensure correct ordering.
Handler mainThread = new Handler(Looper.getMainLooper());
- mainThread.post(new Runnable() {
- @Override
- public void run() {
- mEventLog.add(tag, threadId);
- mEventLog.finish(this.toString());
- }
- });
+ mainThread.post(
+ new Runnable() {
+ @Override
+ public void run() {
+ mEventLog.add(tag, threadId);
+ mEventLog.finish(Request.this.toString());
+ }
+ });
return;
}
@@ -272,7 +259,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Sets the sequence number of this request. Used by {@link RequestQueue}.
+ * Sets the sequence number of this request. Used by {@link RequestQueue}.
*
* @return This Request object to allow for chaining.
*/
@@ -281,9 +268,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return this;
}
- /**
- * Returns the sequence number of this request.
- */
+ /** Returns the sequence number of this request. */
public final int getSequence() {
if (mSequence == null) {
throw new IllegalStateException("getSequence called before setSequence");
@@ -291,23 +276,19 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return mSequence;
}
- /**
- * Returns the URL of this request.
- */
+ /** Returns the URL of this request. */
public String getUrl() {
return mUrl;
}
- /**
- * Returns the cache key for this request. By default, this is the URL.
- */
+ /** Returns the cache key for this request. By default, this is the URL. */
public String getCacheKey() {
return getUrl();
}
/**
- * Annotates this request with an entry retrieved for it from cache.
- * Used for cache coherency support.
+ * Annotates this request with an entry retrieved for it from cache. Used for cache coherency
+ * support.
*
* @return This Request object to allow for chaining.
*/
@@ -316,9 +297,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return this;
}
- /**
- * Returns the annotated cache entry, or null if there isn't one.
- */
+ /** Returns the annotated cache entry, or null if there isn't one. */
public Cache.Entry getCacheEntry() {
return mCacheEntry;
}
@@ -327,17 +306,18 @@ public abstract class Request<T> implements Comparable<Request<T>> {
* Mark this request as canceled.
*
* <p>No callback will be delivered as long as either:
+ *
* <ul>
- * <li>This method is called on the same thread as the {@link ResponseDelivery} is running
- * on. By default, this is the main thread.
- * <li>The request subclass being used overrides cancel() and ensures that it does not
- * invoke the listener in {@link #deliverResponse} after cancel() has been called in a
- * thread-safe manner.
+ * <li>This method is called on the same thread as the {@link ResponseDelivery} is running on.
+ * By default, this is the main thread.
+ * <li>The request subclass being used overrides cancel() and ensures that it does not invoke
+ * the listener in {@link #deliverResponse} after cancel() has been called in a
+ * thread-safe manner.
* </ul>
*
* <p>There are no guarantees if both of these conditions aren't met.
*/
- // @CallSuper
+ @CallSuper
public void cancel() {
synchronized (mLock) {
mCanceled = true;
@@ -345,9 +325,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
}
- /**
- * Returns true if this request has been canceled.
- */
+ /** Returns true if this request has been canceled. */
public boolean isCanceled() {
synchronized (mLock) {
return mCanceled;
@@ -355,9 +333,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Returns a list of extra HTTP headers to go along with this request. Can
- * throw {@link AuthFailureError} as authentication may be required to
- * provide these values.
+ * Returns a list of extra HTTP headers to go along with this request. Can throw {@link
+ * AuthFailureError} as authentication may be required to provide these values.
+ *
* @throws AuthFailureError In the event of auth failure
*/
public Map<String, String> getHeaders() throws AuthFailureError {
@@ -365,14 +343,13 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Returns a Map of POST parameters to be used for this request, or null if
- * a simple GET should be used. Can throw {@link AuthFailureError} as
- * authentication may be required to provide these values.
+ * Returns a Map of POST parameters to be used for this request, or null if a simple GET should
+ * be used. Can throw {@link AuthFailureError} as authentication may be required to provide
+ * these values.
*
- * <p>Note that only one of getPostParams() and getPostBody() can return a non-null
- * value.</p>
- * @throws AuthFailureError In the event of auth failure
+ * <p>Note that only one of getPostParams() and getPostBody() can return a non-null value.
*
+ * @throws AuthFailureError In the event of auth failure
* @deprecated Use {@link #getParams()} instead.
*/
@Deprecated
@@ -381,15 +358,16 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Returns which encoding should be used when converting POST parameters returned by
- * {@link #getPostParams()} into a raw POST body.
+ * Returns which encoding should be used when converting POST parameters returned by {@link
+ * #getPostParams()} into a raw POST body.
*
* <p>This controls both encodings:
+ *
* <ol>
- * <li>The string encoding used when converting parameter names and values into bytes prior
- * to URL encoding them.</li>
- * <li>The string encoding used when converting the URL encoded parameters into a raw
- * byte array.</li>
+ * <li>The string encoding used when converting parameter names and values into bytes prior to
+ * URL encoding them.
+ * <li>The string encoding used when converting the URL encoded parameters into a raw byte
+ * array.
* </ol>
*
* @deprecated Use {@link #getParamsEncoding()} instead.
@@ -399,9 +377,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return getParamsEncoding();
}
- /**
- * @deprecated Use {@link #getBodyContentType()} instead.
- */
+ /** @deprecated Use {@link #getBodyContentType()} instead. */
@Deprecated
public String getPostBodyContentType() {
return getBodyContentType();
@@ -411,7 +387,6 @@ public abstract class Request<T> implements Comparable<Request<T>> {
* Returns the raw POST body to be sent.
*
* @throws AuthFailureError In the event of auth failure
- *
* @deprecated Use {@link #getBody()} instead.
*/
@Deprecated
@@ -428,10 +403,10 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Returns a Map of parameters to be used for a POST or PUT request. Can throw
- * {@link AuthFailureError} as authentication may be required to provide these values.
+ * Returns a Map of parameters to be used for a POST or PUT request. Can throw {@link
+ * AuthFailureError} as authentication may be required to provide these values.
*
- * <p>Note that you can directly override {@link #getBody()} for custom data.</p>
+ * <p>Note that you can directly override {@link #getBody()} for custom data.
*
* @throws AuthFailureError in the event of auth failure
*/
@@ -444,20 +419,19 @@ public abstract class Request<T> implements Comparable<Request<T>> {
* {@link #getParams()} into a raw POST or PUT body.
*
* <p>This controls both encodings:
+ *
* <ol>
- * <li>The string encoding used when converting parameter names and values into bytes prior
- * to URL encoding them.</li>
- * <li>The string encoding used when converting the URL encoded parameters into a raw
- * byte array.</li>
+ * <li>The string encoding used when converting parameter names and values into bytes prior to
+ * URL encoding them.
+ * <li>The string encoding used when converting the URL encoded parameters into a raw byte
+ * array.
* </ol>
*/
protected String getParamsEncoding() {
return DEFAULT_PARAMS_ENCODING;
}
- /**
- * Returns the content type of the POST or PUT body.
- */
+ /** Returns the content type of the POST or PUT body. */
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
}
@@ -479,9 +453,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return null;
}
- /**
- * Converts <code>params</code> into an application/x-www-form-urlencoded encoded string.
- */
+ /** Converts <code>params</code> into an application/x-www-form-urlencoded encoded string. */
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
StringBuilder encodedParams = new StringBuilder();
try {
@@ -507,9 +479,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
return this;
}
- /**
- * Returns true if responses to this request should be cached.
- */
+ /** Returns true if responses to this request should be cached. */
public final boolean shouldCache() {
return mShouldCache;
}
@@ -532,8 +502,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Priority values. Requests will be processed from higher priorities to
- * lower priorities, in FIFO order.
+ * Priority values. Requests will be processed from higher priorities to lower priorities, in
+ * FIFO order.
*/
public enum Priority {
LOW,
@@ -542,32 +512,28 @@ public abstract class Request<T> implements Comparable<Request<T>> {
IMMEDIATE
}
- /**
- * Returns the {@link Priority} of this request; {@link Priority#NORMAL} by default.
- */
+ /** Returns the {@link Priority} of this request; {@link Priority#NORMAL} by default. */
public Priority getPriority() {
return Priority.NORMAL;
}
/**
- * Returns the socket timeout in milliseconds per retry attempt. (This value can be changed
- * per retry attempt if a backoff is specified via backoffTimeout()). If there are no retry
- * attempts remaining, this will cause delivery of a {@link TimeoutError} error.
+ * Returns the socket timeout in milliseconds per retry attempt. (This value can be changed per
+ * retry attempt if a backoff is specified via backoffTimeout()). If there are no retry attempts
+ * remaining, this will cause delivery of a {@link TimeoutError} error.
*/
public final int getTimeoutMs() {
return mRetryPolicy.getCurrentTimeout();
}
- /**
- * Returns the retry policy that should be used for this request.
- */
+ /** Returns the retry policy that should be used for this request. */
public RetryPolicy getRetryPolicy() {
return mRetryPolicy;
}
/**
- * Mark this request as having a response delivered on it. This can be used
- * later in the request's lifetime for suppressing identical responses.
+ * Mark this request as having a response delivered on it. This can be used later in the
+ * request's lifetime for suppressing identical responses.
*/
public void markDelivered() {
synchronized (mLock) {
@@ -575,9 +541,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
}
- /**
- * Returns true if this request has had a response delivered for it.
- */
+ /** Returns true if this request has had a response delivered for it. */
public boolean hasHadResponseDelivered() {
synchronized (mLock) {
return mResponseDelivered;
@@ -585,19 +549,19 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Subclasses must implement this to parse the raw network response
- * and return an appropriate response type. This method will be
- * called from a worker thread. The response will not be delivered
- * if you return null.
+ * Subclasses must implement this to parse the raw network response and return an appropriate
+ * response type. This method will be called from a worker thread. The response will not be
+ * delivered if you return null.
+ *
* @param response Response from the network
* @return The parsed response, or null in the case of an error
*/
- abstract protected Response<T> parseNetworkResponse(NetworkResponse response);
+ protected abstract Response<T> parseNetworkResponse(NetworkResponse response);
/**
* Subclasses can override this method to parse 'networkError' and return a more specific error.
*
- * <p>The default implementation just returns the passed 'networkError'.</p>
+ * <p>The default implementation just returns the passed 'networkError'.
*
* @param volleyError the error retrieved from the network
* @return an NetworkError augmented with additional information
@@ -607,17 +571,17 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Subclasses must implement this to perform delivery of the parsed
- * response to their listeners. The given response is guaranteed to
- * be non-null; responses that fail to parse are not delivered.
- * @param response The parsed response returned by
- * {@link #parseNetworkResponse(NetworkResponse)}
+ * Subclasses must implement this to perform delivery of the parsed response to their listeners.
+ * The given response is guaranteed to be non-null; responses that fail to parse are not
+ * delivered.
+ *
+ * @param response The parsed response returned by {@link
+ * #parseNetworkResponse(NetworkResponse)}
*/
- abstract protected void deliverResponse(T response);
+ protected abstract void deliverResponse(T response);
/**
- * Delivers error message to the ErrorListener that the Request was
- * initialized with.
+ * Delivers error message to the ErrorListener that the Request was initialized with.
*
* @param error Error details
*/
@@ -632,8 +596,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * {@link NetworkRequestCompleteListener} that will receive callbacks when the request
- * returns from the network.
+ * {@link NetworkRequestCompleteListener} that will receive callbacks when the request returns
+ * from the network.
*/
/* package */ void setNetworkRequestCompleteListener(
NetworkRequestCompleteListener requestCompleteListener) {
@@ -643,8 +607,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Notify NetworkRequestCompleteListener that a valid response has been received
- * which can be used for other, waiting requests.
+ * Notify NetworkRequestCompleteListener that a valid response has been received which can be
+ * used for other, waiting requests.
+ *
* @param response received from the network
*/
/* package */ void notifyListenerResponseReceived(Response<?> response) {
@@ -658,8 +623,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Notify NetworkRequestCompleteListener that the network request did not result in
- * a response which can be used for other, waiting requests.
+ * Notify NetworkRequestCompleteListener that the network request did not result in a response
+ * which can be used for other, waiting requests.
*/
/* package */ void notifyListenerResponseNotUsable() {
NetworkRequestCompleteListener listener;
@@ -672,8 +637,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
}
/**
- * Our comparator sorts from high to low priority, and secondarily by
- * sequence number to provide FIFO ordering.
+ * Our comparator sorts from high to low priority, and secondarily by sequence number to provide
+ * FIFO ordering.
*/
@Override
public int compareTo(Request<T> other) {
@@ -682,15 +647,19 @@ public abstract class Request<T> implements Comparable<Request<T>> {
// High-priority requests are "lesser" so they are sorted to the front.
// Equal priorities are sorted by sequence number to provide FIFO ordering.
- return left == right ?
- this.mSequence - other.mSequence :
- right.ordinal() - left.ordinal();
+ return left == right ? this.mSequence - other.mSequence : right.ordinal() - left.ordinal();
}
@Override
public String toString() {
String trafficStatsTag = "0x" + Integer.toHexString(getTrafficStatsTag());
- return (mCanceled ? "[X] " : "[ ] ") + getUrl() + " " + trafficStatsTag + " "
- + getPriority() + " " + mSequence;
+ return (isCanceled() ? "[X] " : "[ ] ")
+ + getUrl()
+ + " "
+ + trafficStatsTag
+ + " "
+ + getPriority()
+ + " "
+ + mSequence;
}
}