Android Developer Console: Error Reports (RejectedExecutionException)

Kevin

Well-Known Member
Licensed User
Longtime User
Splitting out my questions on error reports into separate threads per Erel's request. Also Erel, if you think other might have similar questions I suppose you could consider a separate sub-forum for the sole purpose of others troubleshooting or interpreting these reports if you think it might be worth it.

(Original thread)


RejectedExecutionException: I use the HttpUtilsService and also a custom service which is a modified version of the HttpUtilsService, but apparently this error is coming up in the HttpUtilsService. While I suppose it's possible that the user may be trying to do a bunch of different things at once, other HTTP commands sent outside of the HttpUtilsService should not happen at the same time as commands using the HttpUtilsService, and certainly not enough to exceed the limit, but people seem to try some pretty crazy things. I couldn't use the HttpUtilsService alone because due to the nature of my app, for certain things it wasn't feasible. Again, just wondering if there is a way to trap this error (using Try/Catch) and if so, where?
B4X:
java.lang.RuntimeException: java.util.concurrent.RejectedExecutionException: pool=20/20, queue=0/0
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:145)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.util.concurrent.RejectedExecutionException: pool=20/20, queue=0/0
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1961)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1315)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:85)
at anywheresoftware.b4a.B4AThreadPool.submit(B4AThreadPool.java:39)
at anywheresoftware.b4a.BA.submitRunnable(BA.java:232)
at anywheresoftware.b4a.http.HttpClientWrapper.ExecuteCredentials(HttpClientWrapper.java:294)
at anywheresoftware.b4a.http.HttpClientWrapper.Execute(HttpClientWrapper.java:188)
at com.cognitial.directvremote.httputilsservice._processnexttask(httputilsservice.java:225)
at com.cognitial.directvremote.httputilsservice._hc_responseerror(httputilsservice.java:127)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
... 10 more
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This error happens when the queue of submitted background tasks is larger than 20 tasks.
Normally it should not happen with HttpUtils as HttpUtils throttles the tasks. If you are using two versions of HttpUtils then it might happen.
You can change HttpUtilsService.maxTasks to 5. It will limit each of the "HttpUtils" to 5 running tasks at a time. Note that all your tasks will still run correctly. HttpUtils takes care of submitting them at the right pace.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…