From 802824eb63aaeaa3f3d816ddbe4594b7d888d2ed Mon Sep 17 00:00:00 2001 From: cpacm Date: Thu, 24 Oct 2024 11:37:41 +0800 Subject: [PATCH] When calling ContentProviderClient.release(), on some devices (such as Oppo), a NullPointerException may occur because the IBinder has already been released. --- .../growingio/android/database/EventDataManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/growingio-data/database/src/main/java/com/growingio/android/database/EventDataManager.java b/growingio-data/database/src/main/java/com/growingio/android/database/EventDataManager.java index 35cd3e8e..4df50c23 100644 --- a/growingio-data/database/src/main/java/com/growingio/android/database/EventDataManager.java +++ b/growingio-data/database/src/main/java/com/growingio/android/database/EventDataManager.java @@ -181,7 +181,11 @@ void queryEvents(int policy, int limit, EventDbResult dbResult) { Logger.e(TAG, t, t.getMessage()); } finally { if (client != null) { - client.release(); + try { + client.release(); + } catch (java.lang.NullPointerException e) { + // does nothing, Binder connection already null + } } } } @@ -225,7 +229,11 @@ void queryEventsAndDelete(int policy, int limit, EventDbResult dbResult) { Logger.e(TAG, t, t.getMessage()); } finally { if (client != null) { - client.release(); + try { + client.release(); + } catch (java.lang.NullPointerException e) { + // does nothing, Binder connection already null + } } } }