Merge "Retry and ignore ConcurrentModificationException" am: 93bda73970 am: 8a47dfb768

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772444

Change-Id: I1e449a74117b45fe752decdc02ad3966ded36ef2
This commit is contained in:
Chiachang Wang
2021-07-27 09:35:51 +00:00
committed by Automerger Merge Worker

View File

@@ -3170,7 +3170,18 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
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());
}
}