Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4854c717 authored by paulhu's avatar paulhu Committed by Paul Hu
Browse files

Replace ArrayList with a CopyOnWriteArrayList

RegularMaintenanceJobService use same ArrayList on both
omComplete and onStopJob methods, it's unsafe and will cause
ConcurrentModificationException when reading and removing
value at same time. Thus, replace ArrayList with
a CopyOnWriteArrayList.

Bug: 161205152
Test: atest NetworkStackTests
Change-Id: I3914e9ddc05e37d4deaa8846d7c3ba742160a788
parent 2b0d8046
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;

/**
@@ -65,7 +65,8 @@ public final class RegularMaintenanceJobService extends JobService {
        }
    }

    private static final ArrayList<InterruptMaintenance> sInterruptList = new ArrayList<>();
    private static final CopyOnWriteArrayList<InterruptMaintenance> sInterruptList =
            new CopyOnWriteArrayList<>();
    private static IpMemoryStoreService sIpMemoryStoreService;

    @Override