acsbendi / Android-Request-Inspector-WebView

Inspect and intercept full HTTP requests sent from Android WebViews

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.util.ConcurrentModificationException at RequestInspectorJavaScriptInterface.findRecordedRequestForUrl

alaershov opened this issue · comments

Getting a rare crash in Crashlytics (library version 1.0.2):

Exception: java.util.ConcurrentModificationException:
       at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1029)
       at java.util.ArrayList$Itr.next(ArrayList.java:982)
       at com.acsbendi.requestinspectorwebview.RequestInspectorJavaScriptInterface.findRecordedRequestForUrl(RequestInspectorJavaScriptInterface.kt:21)
       at com.acsbendi.requestinspectorwebview.RequestInspectorWebViewClient.shouldInterceptRequest(RequestInspectorWebViewClient.kt:29)
       at WV.la.a(chromium-TrichromeWebViewGoogle.aab-stable-584517231:80)
       at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle.aab-stable-584517231:15)

There is an ArrayList in the library source code for RequestInspectorJavaScriptInterface:
private val recordedRequests = ArrayList<RecordedRequest>()

I think there should probably be a CopyOnWriteArrayList or maybe a ConcurrentMap instead of ArrayList, or an immutable collection, or maybe another way to ensure thread-safety for correct behavior of concurrent find() and add() calls.

Never mind, I missed the fix in version 1.0.3