From fde45864d2e0360f6902d21e2c913fb1816f2443 Mon Sep 17 00:00:00 2001 From: Mirro Mutth Date: Tue, 6 Feb 2024 15:29:53 +0900 Subject: [PATCH] Use access controller for getting class loader --- src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java b/src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java index 59675e647..4ad301974 100644 --- a/src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java +++ b/src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java @@ -70,6 +70,8 @@ import reactor.core.publisher.SynchronousSink; import reactor.util.concurrent.Queues; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.time.Duration; import java.util.ArrayList; import java.util.Collections; @@ -1079,8 +1081,11 @@ private static String authFails(String authType, String phase) { private static boolean isZstdSupported() { try { - Class.forName("com.github.luben.zstd.Zstd", false, - LoginExchangeable.class.getClassLoader()); + ClassLoader loader = AccessController.doPrivileged((PrivilegedAction) () -> { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + return cl == null ? ClassLoader.getSystemClassLoader() : cl; + }); + Class.forName("com.github.luben.zstd.Zstd", false, loader); return true; } catch (ClassNotFoundException e) { return false;