diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStoreFactory.java b/dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStoreFactory.java index a49f19a4749d..773be9f54607 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStoreFactory.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStoreFactory.java @@ -168,7 +168,6 @@ private static FileCacheStore getFile(String name, boolean enableFileCache) { private static void tryFileLock(FileCacheStore.Builder builder, String fileName) throws PathNotExclusiveException { File lockFile = new File(fileName + ".lock"); - lockFile.deleteOnExit(); FileLock dirLock; try { @@ -188,6 +187,7 @@ private static void tryFileLock(FileCacheStore.Builder builder, String fileName) throw new PathNotExclusiveException(fileName + " is not exclusive. Maybe multiple Dubbo instances are using the same folder."); } + lockFile.deleteOnExit(); builder.directoryLock(dirLock).lockFile(lockFile); }