Panagiotis Triantafyllou

crash fix

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc37'
PUBLISH_VERSION = '4.5.4.6rc38'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Map;
import ly.warp.sdk.io.volley.VolleyLog.MarkerLog;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
......@@ -52,43 +53,67 @@ public abstract class Request<T> implements Comparable<Request<T>> {
int DELETE = 3;
}
/** An event log tracing the lifetime of this request; for debugging. */
/**
* An event log tracing the lifetime of this request; for debugging.
*/
private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null;
/** Request method of this request. Currently supports GET, POST, PUT, and DELETE. */
/**
* Request method of this request. Currently supports GET, POST, PUT, and DELETE.
*/
private final int mMethod;
/** URL of this request. */
/**
* URL of this request.
*/
private final String mUrl;
/** Default tag for {@link TrafficStats}. */
/**
* Default tag for {@link TrafficStats}.
*/
private final int mDefaultTrafficStatsTag;
/** Listener interface for errors. */
/**
* Listener interface for errors.
*/
private final Response.ErrorListener mErrorListener;
/** Sequence number of this request, used to enforce FIFO ordering. */
/**
* Sequence number of this request, used to enforce FIFO ordering.
*/
private Integer mSequence;
/** The request queue this request is associated with. */
/**
* The request queue this request is associated with.
*/
private RequestQueue mRequestQueue;
/** Whether or not responses to this request should be cached. */
/**
* Whether or not responses to this request should be cached.
*/
private boolean mShouldCache = true;
/** Whether or not this request has been canceled. */
/**
* Whether or not this request has been canceled.
*/
private boolean mCanceled = false;
/** Whether or not a response has been delivered for this request yet. */
/**
* Whether or not a response has been delivered for this request yet.
*/
private boolean mResponseDelivered = false;
// A cheap variant of request tracing used to dump slow requests.
private long mRequestBirthTime = 0;
/** Threshold at which we should log the request (even when debug logging is not enabled). */
/**
* Threshold at which we should log the request (even when debug logging is not enabled).
*/
private static final long SLOW_REQUEST_THRESHOLD_MS = 3000;
/** The retry policy for this request. */
/**
* The retry policy for this request.
*/
private RetryPolicy mRetryPolicy;
/**
......@@ -98,7 +123,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*/
private Cache.Entry mCacheEntry = null;
/** An opaque token tagging this request; used for bulk cancellation. */
/**
* An opaque token tagging this request; used for bulk cancellation.
*/
private Object mTag;
/**
......@@ -125,7 +152,17 @@ public abstract class Request<T> implements Comparable<Request<T>> {
mErrorListener = listener;
setRetryPolicy(new DefaultRetryPolicy());
mDefaultTrafficStatsTag = TextUtils.isEmpty(url) ? 0: Uri.parse(url).getHost().hashCode();
if (TextUtils.isEmpty(url)) {
mDefaultTrafficStatsTag = 0;
} else {
if (Uri.parse(url) != null && !TextUtils.isEmpty(Uri.parse(url).getHost())) {
mDefaultTrafficStatsTag = Uri.parse(url).getHost().hashCode();
} else {
mDefaultTrafficStatsTag = 0;
}
}
// mDefaultTrafficStatsTag = TextUtils.isEmpty(url) ? 0: Uri.parse(url).getHost().hashCode();
}
/**
......@@ -145,6 +182,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Returns this request's tag.
*
* @see Request#setTag(Object)
*/
public Object getTag() {
......@@ -283,6 +321,7 @@ 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.
*
* @throws AuthFailureError In the event of auth failure
*/
public Map<String, String> getHeaders() throws AuthFailureError {
......@@ -296,8 +335,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
*
* <p>Note that only one of getPostParams() and getPostBody() can return a non-null
* value.</p>
* @throws AuthFailureError In the event of auth failure
*
* @throws AuthFailureError In the event of auth failure
* @deprecated Use {@link #getParams()} instead.
*/
protected Map<String, String> getPostParams() throws AuthFailureError {
......@@ -333,7 +372,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.
*/
public byte[] getPostBody() throws AuthFailureError {
......@@ -479,6 +517,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
* 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
*/
......@@ -500,8 +539,9 @@ 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)}
* {@link #parseNetworkResponse(NetworkResponse)}
*/
abstract protected void deliverResponse(T response);
......