Merge "Clean up some warnings"
diff --git a/src/com/android/volley/CacheDispatcher.java b/src/com/android/volley/CacheDispatcher.java
index e249437..18d219b 100644
--- a/src/com/android/volley/CacheDispatcher.java
+++ b/src/com/android/volley/CacheDispatcher.java
@@ -29,16 +29,15 @@
* refresh are enqueued on the specified network queue for processing
* by a {@link NetworkDispatcher}.
*/
-@SuppressWarnings("rawtypes")
public class CacheDispatcher extends Thread {
private static final boolean DEBUG = VolleyLog.DEBUG;
/** The queue of requests coming in for triage. */
- private final BlockingQueue<Request> mCacheQueue;
+ private final BlockingQueue<Request<?>> mCacheQueue;
/** The queue of requests going out to the network. */
- private final BlockingQueue<Request> mNetworkQueue;
+ private final BlockingQueue<Request<?>> mNetworkQueue;
/** The cache to read from. */
private final Cache mCache;
@@ -59,7 +58,7 @@
* @param delivery Delivery interface to use for posting responses
*/
public CacheDispatcher(
- BlockingQueue<Request> cacheQueue, BlockingQueue<Request> networkQueue,
+ BlockingQueue<Request<?>> cacheQueue, BlockingQueue<Request<?>> networkQueue,
Cache cache, ResponseDelivery delivery) {
mCacheQueue = cacheQueue;
mNetworkQueue = networkQueue;
@@ -88,7 +87,7 @@
try {
// Get a request from the cache triage queue, blocking until
// at least one is available.
- final Request request = mCacheQueue.take();
+ final Request<?> request = mCacheQueue.take();
request.addMarker("cache-queue-take");
// If the request has been canceled, don't bother dispatching it.
diff --git a/src/com/android/volley/NetworkDispatcher.java b/src/com/android/volley/NetworkDispatcher.java
index 0a82c81..a654ead 100644
--- a/src/com/android/volley/NetworkDispatcher.java
+++ b/src/com/android/volley/NetworkDispatcher.java
@@ -16,6 +16,7 @@
package com.android.volley;
+import android.annotation.TargetApi;
import android.net.TrafficStats;
import android.os.Build;
import android.os.Process;
@@ -30,10 +31,9 @@
* eligible, using a specified {@link Cache} interface. Valid responses and
* errors are posted back to the caller via a {@link ResponseDelivery}.
*/
-@SuppressWarnings("rawtypes")
public class NetworkDispatcher extends Thread {
/** The queue of requests to service. */
- private final BlockingQueue<Request> mQueue;
+ private final BlockingQueue<Request<?>> mQueue;
/** The network interface for processing requests. */
private final Network mNetwork;
/** The cache to write to. */
@@ -52,7 +52,7 @@
* @param cache Cache interface to use for writing responses to cache
* @param delivery Delivery interface to use for posting responses
*/
- public NetworkDispatcher(BlockingQueue<Request> queue,
+ public NetworkDispatcher(BlockingQueue<Request<?>> queue,
Network network, Cache cache,
ResponseDelivery delivery) {
mQueue = queue;
@@ -70,10 +70,18 @@
interrupt();
}
+ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
+ private void addTrafficStatsTag(Request<?> request) {
+ // Tag the request (if API >= 14)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ TrafficStats.setThreadStatsTag(request.getTrafficStatsTag());
+ }
+ }
+
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- Request request;
+ Request<?> request;
while (true) {
try {
// Take a request from the queue.
@@ -96,10 +104,7 @@
continue;
}
- // Tag the request (if API >= 14)
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- TrafficStats.setThreadStatsTag(request.getTrafficStatsTag());
- }
+ addTrafficStatsTag(request);
// Perform the network request.
NetworkResponse networkResponse = mNetwork.performRequest(request);
diff --git a/src/com/android/volley/RequestQueue.java b/src/com/android/volley/RequestQueue.java
index bcd86f6..bfcd7d4 100644
--- a/src/com/android/volley/RequestQueue.java
+++ b/src/com/android/volley/RequestQueue.java
@@ -35,7 +35,6 @@
* resolving from either cache or network on a worker thread, and then delivering
* a parsed response on the main thread.
*/
-@SuppressWarnings("rawtypes")
public class RequestQueue {
/** Used for generating monotonically-increasing sequence numbers for requests. */
@@ -51,28 +50,28 @@
* is <em>not</em> contained in that list. Is null if no requests are staged.</li>
* </ul>
*/
- private final Map<String, Queue<Request>> mWaitingRequests =
- new HashMap<String, Queue<Request>>();
+ private final Map<String, Queue<Request<?>>> mWaitingRequests =
+ new HashMap<String, Queue<Request<?>>>();
/**
* The set of all requests currently being processed by this RequestQueue. A Request
* will be in this set if it is waiting in any queue or currently being processed by
* any dispatcher.
*/
- private final Set<Request> mCurrentRequests = new HashSet<Request>();
+ private final Set<Request<?>> mCurrentRequests = new HashSet<Request<?>>();
/** The cache triage queue. */
- private final PriorityBlockingQueue<Request> mCacheQueue =
- new PriorityBlockingQueue<Request>();
+ private final PriorityBlockingQueue<Request<?>> mCacheQueue =
+ new PriorityBlockingQueue<Request<?>>();
/** The queue of requests that are actually going out to the network. */
- private final PriorityBlockingQueue<Request> mNetworkQueue =
- new PriorityBlockingQueue<Request>();
+ private final PriorityBlockingQueue<Request<?>> mNetworkQueue =
+ new PriorityBlockingQueue<Request<?>>();
/** Number of network request dispatcher threads to start. */
private static final int DEFAULT_NETWORK_THREAD_POOL_SIZE = 4;
- /** Cache interface for retrieving and storing respones. */
+ /** Cache interface for retrieving and storing responses. */
private final Cache mCache;
/** Network interface for performing requests. */
@@ -214,7 +213,7 @@
* @param request The request to service
* @return The passed-in request
*/
- public Request add(Request request) {
+ public Request<?> add(Request<?> request) {
// Tag the request as belonging to this queue and add it to the set of current requests.
request.setRequestQueue(this);
synchronized (mCurrentRequests) {
@@ -236,9 +235,9 @@
String cacheKey = request.getCacheKey();
if (mWaitingRequests.containsKey(cacheKey)) {
// There is already a request in flight. Queue up.
- Queue<Request> stagedRequests = mWaitingRequests.get(cacheKey);
+ Queue<Request<?>> stagedRequests = mWaitingRequests.get(cacheKey);
if (stagedRequests == null) {
- stagedRequests = new LinkedList<Request>();
+ stagedRequests = new LinkedList<Request<?>>();
}
stagedRequests.add(request);
mWaitingRequests.put(cacheKey, stagedRequests);
@@ -262,7 +261,7 @@
* <p>Releases waiting requests for <code>request.getCacheKey()</code> if
* <code>request.shouldCache()</code>.</p>
*/
- void finish(Request request) {
+ void finish(Request<?> request) {
// Remove from the set of requests currently being processed.
synchronized (mCurrentRequests) {
mCurrentRequests.remove(request);
@@ -271,7 +270,7 @@
if (request.shouldCache()) {
synchronized (mWaitingRequests) {
String cacheKey = request.getCacheKey();
- Queue<Request> waitingRequests = mWaitingRequests.remove(cacheKey);
+ Queue<Request<?>> waitingRequests = mWaitingRequests.remove(cacheKey);
if (waitingRequests != null) {
if (VolleyLog.DEBUG) {
VolleyLog.v("Releasing %d waiting requests for cacheKey=%s.",
diff --git a/src/com/android/volley/toolbox/AndroidAuthenticator.java b/src/com/android/volley/toolbox/AndroidAuthenticator.java
index a2c6ac9..371fd83 100644
--- a/src/com/android/volley/toolbox/AndroidAuthenticator.java
+++ b/src/com/android/volley/toolbox/AndroidAuthenticator.java
@@ -67,6 +67,8 @@
return mAccount;
}
+ // TODO: Figure out what to do about notifyAuthFailure
+ @SuppressWarnings("deprecation")
@Override
public String getAuthToken() throws AuthFailureError {
final AccountManager accountManager = AccountManager.get(mContext);
diff --git a/tests/src/com/android/volley/RequestQueueTest.java b/tests/src/com/android/volley/RequestQueueTest.java
index f456887..f99ff8e 100644
--- a/tests/src/com/android/volley/RequestQueueTest.java
+++ b/tests/src/com/android/volley/RequestQueueTest.java
@@ -178,7 +178,7 @@
private final AtomicInteger mDeliveredCount;
public DelayedRequest(long delayMillis, AtomicInteger parsed, AtomicInteger delivered) {
- super("http://buganizer/", null);
+ super(Request.Method.GET, "http://buganizer/", null);
mDelayMillis = delayMillis;
mParsedCount = parsed;
mDeliveredCount = delivered;
diff --git a/tests/src/com/android/volley/RequestTest.java b/tests/src/com/android/volley/RequestTest.java
index d690bd8..213e6cd 100644
--- a/tests/src/com/android/volley/RequestTest.java
+++ b/tests/src/com/android/volley/RequestTest.java
@@ -51,7 +51,7 @@
private class TestRequest extends Request<Object> {
private Priority mPriority = Priority.NORMAL;
public TestRequest(Priority priority) {
- super("", null);
+ super(Request.Method.GET, "", null);
mPriority = priority;
}
diff --git a/tests/src/com/android/volley/mock/MockHttpStack.java b/tests/src/com/android/volley/mock/MockHttpStack.java
index 2c463e5..9594fde 100644
--- a/tests/src/com/android/volley/mock/MockHttpStack.java
+++ b/tests/src/com/android/volley/mock/MockHttpStack.java
@@ -63,7 +63,7 @@
mLastHeaders.putAll(additionalHeaders);
}
try {
- mLastPostBody = request.getPostBody();
+ mLastPostBody = request.getBody();
} catch (AuthFailureError e) {
mLastPostBody = null;
}
diff --git a/tests/src/com/android/volley/mock/MockRequest.java b/tests/src/com/android/volley/mock/MockRequest.java
index 3267c3d..9815ea8 100644
--- a/tests/src/com/android/volley/mock/MockRequest.java
+++ b/tests/src/com/android/volley/mock/MockRequest.java
@@ -28,11 +28,11 @@
public class MockRequest extends Request<byte[]> {
public MockRequest() {
- super("http://foo.com", null);
+ super(Request.Method.GET, "http://foo.com", null);
}
public MockRequest(String url, ErrorListener listener) {
- super(url, listener);
+ super(Request.Method.GET, url, listener);
}
private Map<String, String> mPostParams = new HashMap<String, String>();
diff --git a/tests/src/com/android/volley/mock/WaitableQueue.java b/tests/src/com/android/volley/mock/WaitableQueue.java
index a3d54aa..079bbf5 100644
--- a/tests/src/com/android/volley/mock/WaitableQueue.java
+++ b/tests/src/com/android/volley/mock/WaitableQueue.java
@@ -26,8 +26,8 @@
import java.util.concurrent.TimeoutException;
// TODO: the name of this class sucks
-@SuppressWarnings({ "serial", "rawtypes" })
-public class WaitableQueue extends PriorityBlockingQueue<Request> {
+@SuppressWarnings("serial")
+public class WaitableQueue extends PriorityBlockingQueue<Request<?>> {
private final Request<?> mStopRequest = new MagicStopRequest();
private final Semaphore mStopEvent = new Semaphore(0);
@@ -52,7 +52,7 @@
private static class MagicStopRequest extends Request<Object> {
public MagicStopRequest() {
- super("", null);
+ super(Request.Method.GET, "", null);
}
@Override
diff --git a/tests/src/com/android/volley/toolbox/BasicNetworkTest.java b/tests/src/com/android/volley/toolbox/BasicNetworkTest.java
index bdc6cfe..ccbb1e8 100644
--- a/tests/src/com/android/volley/toolbox/BasicNetworkTest.java
+++ b/tests/src/com/android/volley/toolbox/BasicNetworkTest.java
@@ -47,7 +47,7 @@
fakeResponse.setEntity(new StringEntity("foobar"));
mockHttpStack.setResponseToReturn(fakeResponse);
BasicNetwork httpNetwork = new BasicNetwork(mockHttpStack);
- Request<String> request = new Request<String>("http://foo", null) {
+ Request<String> request = new Request<String>(Request.Method.GET, "http://foo", null) {
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
@@ -66,7 +66,7 @@
}
@Override
- public Map<String, String> getPostParams() {
+ public Map<String, String> getParams() {
Map<String, String> result = new HashMap<String, String>();
result.put("requestpost", "foo");
return result;