From 9b0f1c61a2f877e1755c3d5cbc9f811e2aa4e665 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 22 Aug 2025 16:04:39 -0700 Subject: [PATCH] Fallback to working dir for native lib dir in tests When finding the platform dir to pass to jna we check for system properties which are either set by internal test gradle code or or the cli shell script. If neither of thse are set, we are in test code for an external plugin. This commit fixes the code to use the working dir in this fallback case. Previously we would have created a bogus path. Both are the same: external plugin tests can't load ES native libs since they don't have them available. --- .../elasticsearch/nativeaccess/lib/LoaderHelper.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/native/src/main/java/org/elasticsearch/nativeaccess/lib/LoaderHelper.java b/libs/native/src/main/java/org/elasticsearch/nativeaccess/lib/LoaderHelper.java index 98887381e5d40..1401d8d5b48e4 100644 --- a/libs/native/src/main/java/org/elasticsearch/nativeaccess/lib/LoaderHelper.java +++ b/libs/native/src/main/java/org/elasticsearch/nativeaccess/lib/LoaderHelper.java @@ -26,7 +26,16 @@ private static Path findPlatformLibDir() { return Paths.get(path); } - Path homeDir = Paths.get(System.getProperty("es.path.home")); + String homeDirPath = System.getProperty("es.path.home"); + if (homeDirPath == null) { + // if we don't have the native libs passed in for tests, and we don't have the home dir set + // then we must be in a test for an external plugin. there's nothing we can do to get the + // native libs, they don't exist, so just return the working dir, it will fail if the test + // actually tries to load a library + return Paths.get(""); + } + + Path homeDir = Paths.get(homeDirPath); Path platformDir = homeDir.resolve("lib/platform"); String osname = System.getProperty("os.name");