diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java index 6fe5a4a72..38191ac0f 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java @@ -150,10 +150,14 @@ public class DiskCache { private static File makeSureCacheDirExists(String dir) { File cacheDir = new File(dir); - if (!cacheDir.exists() && !cacheDir.mkdirs()) { - throw new IllegalStateException("failed to create cache dir: " + dir); + + if (!cacheDir.exists()) { + if (!cacheDir.mkdirs() && !cacheDir.exists()) { + throw new IllegalStateException("failed to create cache dir: " + dir); + } } + return cacheDir; } }