From 4ed7aa350ba371386240128fce739c7b9029dbfd Mon Sep 17 00:00:00 2001 From: wangchenjun Date: Tue, 17 Sep 2019 16:34:06 +0800 Subject: [PATCH] Avoiding conflicted for creating directory. --- .../com/alibaba/nacos/client/naming/cache/DiskCache.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; } }