From a8c72dd392b42bca983d2e56a9e1753774b2683f Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Thu, 17 Oct 2024 10:45:41 +0200 Subject: [PATCH] Fix ensure ndk libs are loaded before calling close (#3797) --- .../main/java/io/sentry/android/ndk/SentryNdk.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java b/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java index 7245516b49..3429780eec 100644 --- a/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java +++ b/sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdk.java @@ -69,6 +69,15 @@ public static void init(@NotNull final SentryAndroidOptions options) { /** Closes the NDK integration */ public static void close() { - shutdown(); + try { + if (loadLibraryLatch.await(2000, TimeUnit.MILLISECONDS)) { + shutdown(); + } else { + throw new IllegalStateException("Timeout waiting for Sentry NDK library to load"); + } + } catch (InterruptedException e) { + throw new IllegalStateException( + "Thread interrupted while waiting for NDK libs to be loaded", e); + } } }