From 2007081f2d1570c32903e0b5a45a363014295dda Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sun, 4 Feb 2024 18:50:02 +0000 Subject: [PATCH] Simplify mapping not null when loading embedded library. Signed-off-by: Kenneth J. Shackleton --- .../kotlin/com/bloomberg/selekt/commons/NativeResources.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selekt-java/src/main/kotlin/com/bloomberg/selekt/commons/NativeResources.kt b/selekt-java/src/main/kotlin/com/bloomberg/selekt/commons/NativeResources.kt index 7e46397aab..16fb7009f2 100644 --- a/selekt-java/src/main/kotlin/com/bloomberg/selekt/commons/NativeResources.kt +++ b/selekt-java/src/main/kotlin/com/bloomberg/selekt/commons/NativeResources.kt @@ -59,9 +59,9 @@ internal fun libraryResourceNames( @Throws(IOException::class) fun loadEmbeddedLibrary(loader: ClassLoader, parentDirectory: String, name: String) { - val url = checkNotNull(libraryResourceNames(parentDirectory, name).mapNotNull { + val url = checkNotNull(libraryResourceNames(parentDirectory, name).firstNotNullOfOrNull { loader.getResource(it) - }.firstOrNull()) { "Failed to find resource with name: $name" } + }) { "Failed to find resource with name: $name" } @Suppress("NewApi") // Not used by Android. val file = createTempFile("lib$name", "lib").toFile().apply { deleteOnExit() } try {