diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index 43e8676e2a741b98047d21eb00b27253953d07fb..a37cf31523a8f1864edc57960782ea7357721e4f 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -3162,7 +3162,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()); } }