Skip to content

Commit

Permalink
Use access controller for getting class loader
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Feb 13, 2024
1 parent c4f3972 commit fde4586
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/io/asyncer/r2dbc/mysql/QueryFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>) () -> {
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;
Expand Down

0 comments on commit fde4586

Please sign in to comment.