diff --git a/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java b/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java index 8d7da1e334..3c36c4bb2e 100644 --- a/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java +++ b/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java @@ -28,18 +28,18 @@ public class ShuffleServerClientFactory { - private static ShuffleServerClientFactory INSTANCE; private Map> clients; private ShuffleServerClientFactory() { clients = Maps.newConcurrentMap(); } - public static synchronized ShuffleServerClientFactory getInstance() { - if (INSTANCE == null) { - INSTANCE = new ShuffleServerClientFactory(); - } - return INSTANCE; + private static class LazyHolder { + static final ShuffleServerClientFactory INSTANCE = new ShuffleServerClientFactory(); + } + + public static ShuffleServerClientFactory getInstance() { + return LazyHolder.INSTANCE; } private ShuffleServerClient createShuffleServerClient(String clientType, ShuffleServerInfo shuffleServerInfo) {