From bcbdcc84b63e656e6fe7b27a92660e6f07877fc5 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Wed, 16 Oct 2024 11:19:40 +0200 Subject: [PATCH] Fix ensure ndk libs are loaded before calling close --- .../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); + } } }