Panagiotis Triantafyllou

crash fix

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.6rc37' 5 + PUBLISH_VERSION = '4.5.4.6rc38'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -22,6 +22,7 @@ import java.util.Collections; ...@@ -22,6 +22,7 @@ import java.util.Collections;
22 import java.util.Map; 22 import java.util.Map;
23 23
24 import ly.warp.sdk.io.volley.VolleyLog.MarkerLog; 24 import ly.warp.sdk.io.volley.VolleyLog.MarkerLog;
25 +
25 import android.net.TrafficStats; 26 import android.net.TrafficStats;
26 import android.net.Uri; 27 import android.net.Uri;
27 import android.os.Handler; 28 import android.os.Handler;
...@@ -52,43 +53,67 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -52,43 +53,67 @@ public abstract class Request<T> implements Comparable<Request<T>> {
52 int DELETE = 3; 53 int DELETE = 3;
53 } 54 }
54 55
55 - /** An event log tracing the lifetime of this request; for debugging. */ 56 + /**
57 + * An event log tracing the lifetime of this request; for debugging.
58 + */
56 private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null; 59 private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null;
57 60
58 - /** Request method of this request. Currently supports GET, POST, PUT, and DELETE. */ 61 + /**
62 + * Request method of this request. Currently supports GET, POST, PUT, and DELETE.
63 + */
59 private final int mMethod; 64 private final int mMethod;
60 65
61 - /** URL of this request. */ 66 + /**
67 + * URL of this request.
68 + */
62 private final String mUrl; 69 private final String mUrl;
63 70
64 - /** Default tag for {@link TrafficStats}. */ 71 + /**
72 + * Default tag for {@link TrafficStats}.
73 + */
65 private final int mDefaultTrafficStatsTag; 74 private final int mDefaultTrafficStatsTag;
66 75
67 - /** Listener interface for errors. */ 76 + /**
77 + * Listener interface for errors.
78 + */
68 private final Response.ErrorListener mErrorListener; 79 private final Response.ErrorListener mErrorListener;
69 80
70 - /** Sequence number of this request, used to enforce FIFO ordering. */ 81 + /**
82 + * Sequence number of this request, used to enforce FIFO ordering.
83 + */
71 private Integer mSequence; 84 private Integer mSequence;
72 85
73 - /** The request queue this request is associated with. */ 86 + /**
87 + * The request queue this request is associated with.
88 + */
74 private RequestQueue mRequestQueue; 89 private RequestQueue mRequestQueue;
75 90
76 - /** Whether or not responses to this request should be cached. */ 91 + /**
92 + * Whether or not responses to this request should be cached.
93 + */
77 private boolean mShouldCache = true; 94 private boolean mShouldCache = true;
78 95
79 - /** Whether or not this request has been canceled. */ 96 + /**
97 + * Whether or not this request has been canceled.
98 + */
80 private boolean mCanceled = false; 99 private boolean mCanceled = false;
81 100
82 - /** Whether or not a response has been delivered for this request yet. */ 101 + /**
102 + * Whether or not a response has been delivered for this request yet.
103 + */
83 private boolean mResponseDelivered = false; 104 private boolean mResponseDelivered = false;
84 105
85 // A cheap variant of request tracing used to dump slow requests. 106 // A cheap variant of request tracing used to dump slow requests.
86 private long mRequestBirthTime = 0; 107 private long mRequestBirthTime = 0;
87 108
88 - /** Threshold at which we should log the request (even when debug logging is not enabled). */ 109 + /**
110 + * Threshold at which we should log the request (even when debug logging is not enabled).
111 + */
89 private static final long SLOW_REQUEST_THRESHOLD_MS = 3000; 112 private static final long SLOW_REQUEST_THRESHOLD_MS = 3000;
90 113
91 - /** The retry policy for this request. */ 114 + /**
115 + * The retry policy for this request.
116 + */
92 private RetryPolicy mRetryPolicy; 117 private RetryPolicy mRetryPolicy;
93 118
94 /** 119 /**
...@@ -98,7 +123,9 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -98,7 +123,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
98 */ 123 */
99 private Cache.Entry mCacheEntry = null; 124 private Cache.Entry mCacheEntry = null;
100 125
101 - /** An opaque token tagging this request; used for bulk cancellation. */ 126 + /**
127 + * An opaque token tagging this request; used for bulk cancellation.
128 + */
102 private Object mTag; 129 private Object mTag;
103 130
104 /** 131 /**
...@@ -125,7 +152,17 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -125,7 +152,17 @@ public abstract class Request<T> implements Comparable<Request<T>> {
125 mErrorListener = listener; 152 mErrorListener = listener;
126 setRetryPolicy(new DefaultRetryPolicy()); 153 setRetryPolicy(new DefaultRetryPolicy());
127 154
128 - mDefaultTrafficStatsTag = TextUtils.isEmpty(url) ? 0: Uri.parse(url).getHost().hashCode(); 155 + if (TextUtils.isEmpty(url)) {
156 + mDefaultTrafficStatsTag = 0;
157 + } else {
158 + if (Uri.parse(url) != null && !TextUtils.isEmpty(Uri.parse(url).getHost())) {
159 + mDefaultTrafficStatsTag = Uri.parse(url).getHost().hashCode();
160 + } else {
161 + mDefaultTrafficStatsTag = 0;
162 + }
163 + }
164 +
165 +// mDefaultTrafficStatsTag = TextUtils.isEmpty(url) ? 0: Uri.parse(url).getHost().hashCode();
129 } 166 }
130 167
131 /** 168 /**
...@@ -145,6 +182,7 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -145,6 +182,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
145 182
146 /** 183 /**
147 * Returns this request's tag. 184 * Returns this request's tag.
185 + *
148 * @see Request#setTag(Object) 186 * @see Request#setTag(Object)
149 */ 187 */
150 public Object getTag() { 188 public Object getTag() {
...@@ -283,6 +321,7 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -283,6 +321,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
283 * Returns a list of extra HTTP headers to go along with this request. Can 321 * Returns a list of extra HTTP headers to go along with this request. Can
284 * throw {@link AuthFailureError} as authentication may be required to 322 * throw {@link AuthFailureError} as authentication may be required to
285 * provide these values. 323 * provide these values.
324 + *
286 * @throws AuthFailureError In the event of auth failure 325 * @throws AuthFailureError In the event of auth failure
287 */ 326 */
288 public Map<String, String> getHeaders() throws AuthFailureError { 327 public Map<String, String> getHeaders() throws AuthFailureError {
...@@ -296,8 +335,8 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -296,8 +335,8 @@ public abstract class Request<T> implements Comparable<Request<T>> {
296 * 335 *
297 * <p>Note that only one of getPostParams() and getPostBody() can return a non-null 336 * <p>Note that only one of getPostParams() and getPostBody() can return a non-null
298 * value.</p> 337 * value.</p>
299 - * @throws AuthFailureError In the event of auth failure
300 * 338 *
339 + * @throws AuthFailureError In the event of auth failure
301 * @deprecated Use {@link #getParams()} instead. 340 * @deprecated Use {@link #getParams()} instead.
302 */ 341 */
303 protected Map<String, String> getPostParams() throws AuthFailureError { 342 protected Map<String, String> getPostParams() throws AuthFailureError {
...@@ -333,7 +372,6 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -333,7 +372,6 @@ public abstract class Request<T> implements Comparable<Request<T>> {
333 * Returns the raw POST body to be sent. 372 * Returns the raw POST body to be sent.
334 * 373 *
335 * @throws AuthFailureError In the event of auth failure 374 * @throws AuthFailureError In the event of auth failure
336 - *
337 * @deprecated Use {@link #getBody()} instead. 375 * @deprecated Use {@link #getBody()} instead.
338 */ 376 */
339 public byte[] getPostBody() throws AuthFailureError { 377 public byte[] getPostBody() throws AuthFailureError {
...@@ -479,6 +517,7 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -479,6 +517,7 @@ public abstract class Request<T> implements Comparable<Request<T>> {
479 * and return an appropriate response type. This method will be 517 * and return an appropriate response type. This method will be
480 * called from a worker thread. The response will not be delivered 518 * called from a worker thread. The response will not be delivered
481 * if you return null. 519 * if you return null.
520 + *
482 * @param response Response from the network 521 * @param response Response from the network
483 * @return The parsed response, or null in the case of an error 522 * @return The parsed response, or null in the case of an error
484 */ 523 */
...@@ -500,8 +539,9 @@ public abstract class Request<T> implements Comparable<Request<T>> { ...@@ -500,8 +539,9 @@ public abstract class Request<T> implements Comparable<Request<T>> {
500 * Subclasses must implement this to perform delivery of the parsed 539 * Subclasses must implement this to perform delivery of the parsed
501 * response to their listeners. The given response is guaranteed to 540 * response to their listeners. The given response is guaranteed to
502 * be non-null; responses that fail to parse are not delivered. 541 * be non-null; responses that fail to parse are not delivered.
542 + *
503 * @param response The parsed response returned by 543 * @param response The parsed response returned by
504 - * {@link #parseNetworkResponse(NetworkResponse)} 544 + * {@link #parseNetworkResponse(NetworkResponse)}
505 */ 545 */
506 abstract protected void deliverResponse(T response); 546 abstract protected void deliverResponse(T response);
507 547
......