In my project I am using Firebase Storage to download some image files - 154 images to be exact. For some unknown reason to me I only manage to download only around 130 files and then I get an exception stating:
java.util.concurrent.RejectedExecutionException: Task com.google.firebase.storage.zzs@15c1d59d rejected from java.util.concurrent.ThreadPoolExecutor@270bfa12[Running, pool size = 3, active threads = 3, queued tasks = 128, completed tasks = 5] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339) at com.google.firebase.storage.zzu.zzv(Unknown Source) at com.google.firebase.storage.FileDownloadTask.schedule(Unknown Source) at com.google.firebase.storage.StorageTask.zzcny(Unknown Source) at com.google.firebase.storage.StorageReference.getFile(Unknown Source) at com.google.firebase.storage.StorageReference.getFile(Unknown Source)
I am using for loop to call StorageReference.getFile() and download the file in specific location like this:
for (int i = 0; i < filesToDownload.size(); i++) {
String image = filesToDownload.get(i);
final File localFile = new
File(DeviceStorage.getExternalStorageDir(dirPath)
+ File.separator + fileName);
StorageReference downloadPhotoRef =
getReference().child(folderName + File.separator + fileName);
downloadPhotoRef.getFile(localFile);
downloadFile(context, image);
}
I am really puzzled why does this happen. I couldn't find any solutions and other people having the same problem. I run this code in a Service. The only way I don't get the error is if I'm downloading less than 130 files, but this is no good to me.
Please help.