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

Commit b38b5510 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure ScheduledExecutor is not shutdown before scheduling timeout cleanup." into main

parents 37c4e48e dd63d318
Loading
Loading
Loading
Loading
+27 −14
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -1660,14 +1661,20 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        }
                    }
                };
                if (mScheduledExecutor != null) {
                if (mScheduledExecutor != null && !mScheduledExecutor.isShutdown()) {
                    try {
                        // Post cleanup to the executor service and cache the future,
                        // so we can cancel it if needed.
                        ScheduledFuture<?> future = mScheduledExecutor.schedule(
                        r.getRunnableToCancel(),SERVICE_BINDING_TIMEOUT, TimeUnit.MILLISECONDS);
                                r.getRunnableToCancel(),SERVICE_BINDING_TIMEOUT,
                                TimeUnit.MILLISECONDS);
                        mScheduledFutureMap.put(call, future);
                    } catch (RejectedExecutionException e) {
                        Log.e(this, e, "createConference: mScheduledExecutor was "
                                + "already shutdown");
                    }
                } else {
                    Log.w(this, "createConference: Scheduled executor is null");
                    Log.w(this, "createConference: Scheduled executor is null or shutdown");
                    mAnomalyReporter.reportAnomaly(
                        NULL_SCHEDULED_EXECUTOR_ERROR_UUID,
                        NULL_SCHEDULED_EXECUTOR_ERROR_MSG);
@@ -1796,14 +1803,20 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        }
                    }
                };
                if (mScheduledExecutor != null) {
                if (mScheduledExecutor != null && !mScheduledExecutor.isShutdown()) {
                    try {
                        // Post cleanup to the executor service and cache the future,
                        // so we can cancel it if needed.
                        ScheduledFuture<?> future = mScheduledExecutor.schedule(
                        r.getRunnableToCancel(),SERVICE_BINDING_TIMEOUT, TimeUnit.MILLISECONDS);
                                r.getRunnableToCancel(),SERVICE_BINDING_TIMEOUT,
                                TimeUnit.MILLISECONDS);
                        mScheduledFutureMap.put(call, future);
                    } catch (RejectedExecutionException e) {
                        Log.e(this, e, "createConnection: mScheduledExecutor was "
                                + "already shutdown");
                    }
                } else {
                    Log.w(this, "createConnection: Scheduled executor is null");
                    Log.w(this, "createConnection: Scheduled executor is null or shutdown");
                    mAnomalyReporter.reportAnomaly(
                        NULL_SCHEDULED_EXECUTOR_ERROR_UUID,
                        NULL_SCHEDULED_EXECUTOR_ERROR_MSG);