From 2ea2b1682424600f5c9bdc9d57e1110ccea753a0 Mon Sep 17 00:00:00 2001 From: Chienyuan Date: Mon, 17 Dec 2018 21:31:40 +0800 Subject: [PATCH] BluetoothManagerService: catch NoSuchElementException for unlinkToDeath linkToDeath fail will cause NoSuchElementException when following unlinkToDeath, add try catch to handle it. Bug: 121104808 Test: build pass Change-Id: I2f3337ad417567ea3b4dea3eb004c60f96527c41 --- services/core/java/com/android/server/BluetoothManagerService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 78b738500a97..8f5b228e7203 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -76,6 +76,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Locale; import java.util.Map; +import java.util.NoSuchElementException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -1259,7 +1260,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub { if (mService == null) { return; } - mService.unlinkToDeath(this, 0); + try { + mService.unlinkToDeath(this, 0); + } catch (NoSuchElementException e) { + Log.e(TAG, "error unlinking to death", e); + } mService = null; mClassName = null; -- 2.11.0