commit | 8a47dfb768708eb6e134738f52e89c16fb3f480f | [log] [tgz] |
---|---|---|
author | Chiachang Wang <chiachangwang@google.com> | Tue Jul 27 09:18:12 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Jul 27 09:18:12 2021 +0000 |
tree | c615119200a26bf758cffac643a66fb4ee06f892 | |
parent | d79bd5c622d7a76b37a71f8f131697cba079c6e9 [diff] | |
parent | 93bda73970778d94cca72ba81524f72345dd0e45 [diff] |
Merge "Retry and ignore ConcurrentModificationException" am: 93bda73970 Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772444 Change-Id: Iffac4efceaac6b8d27b794c638ecb3358aeeff0a
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index 43e8676..a37cf31 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java
@@ -3162,7 +3162,18 @@ } private void dumpNetworkRequests(IndentingPrintWriter pw) { - for (NetworkRequestInfo nri : requestsSortedById()) { + NetworkRequestInfo[] infos = null; + while (infos == null) { + try { + infos = requestsSortedById(); + } catch (ConcurrentModificationException e) { + // mNetworkRequests should only be accessed from handler thread, except dump(). + // As dump() is never called in normal usage, it would be needlessly expensive + // to lock the collection only for its benefit. Instead, retry getting the + // requests if ConcurrentModificationException is thrown during dump(). + } + } + for (NetworkRequestInfo nri : infos) { pw.println(nri.toString()); } }