I'm getting the following error in a crashlytics report and I'm having a little trouble figuring out where it's coming from or how to resolve it.
The reason I'm confused - is the crash seems to reference the Volley library it's-self, not any code I've actually written (nothing in the crash seems to point to any of my code).
Does anyone know how or what I might be able to do to resolve this crash?
Any suggestions are GREATLY appreciated.
Fatal Error:
Fatal Exception: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$ValueIterator.next(HashMap.java:819)
at com.android.volley.toolbox.ImageLoader$4.run(ImageLoader.java:464)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Source:
public class VolleyManager {
private static final String TAG = VolleyManager.class.getSimpleName();
/** Number of network request dispatcher threads to start. */
private static final int DEFAULT_NETWORK_THREAD_POOL_SIZE = 4;
private static VolleyManager mInstance;
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static Context mContext;
private VolleyManager(Context context) {
mContext = context.getApplicationContext();
mRequestQueue = getRequestQueue();
}
public static synchronized VolleyManager getInstance(Context context) {
if (mInstance == null) {
mInstance = new VolleyManager(context);
}
return mInstance;
}
@SuppressWarnings("deprecation")
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
File cacheDir = new File(FMCacheManager.getCacheBaseDir(mContext));
String userAgent = "volley/0";
try {
String packageName = mContext.getPackageName();
PackageInfo info = mContext.getPackageManager().getPackageInfo(packageName, 0);
userAgent = packageName + "/" + info.versionCode;
} catch (NameNotFoundException ignore) {
}
HttpStack stack = new HurlStack();
Network network = new BasicNetwork(stack);
HandlerThread mHandlerThread = new HandlerThread(TAG, android.os.Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
ResponseDelivery delivery = new ExecutorDelivery(new Handler(mHandlerThread.getLooper()));
RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, DEFAULT_NETWORK_THREAD_POOL_SIZE, delivery);
queue.start();
mRequestQueue = queue;
}
return mRequestQueue;
}
public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
mImageLoader = new ImageLoader(this.mRequestQueue,
new LruBitmapCache());
}
return this.mImageLoader;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
if (req != null) {
Log.d(TAG, "request: " + req.getUrl());
// set the default tag if tag is empty
req.setTag(FMUtils.isNullOrEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}