davinci
davinci copied to clipboard
error in SystemSchedule.clearTempDir()
why format the path before delete dir? formatFilePath will change the folder path from absolute path to relative path. this change cause the delete failed.
final String download = fileUtils.formatFilePath(downloadDir);
final String temp = fileUtils.formatFilePath(tempDir);
final String csv = fileUtils.formatFilePath(csvDir);
CLEAR_TEMPDIR_THREADPOOL.execute(() -> FileUtils.deleteDir(new File(download)));
CLEAR_TEMPDIR_THREADPOOL.execute(() -> FileUtils.deleteDir(new File(temp)));
CLEAR_TEMPDIR_THREADPOOL.execute(() -> FileUtils.deleteDir(new File(csv)));
public String formatFilePath(String filePath) {
if(filePath == null) {
return null;
}
return filePath.**replace(fileBasePath, EMPTY)**.replaceAll(File.separator + "{2,}", File.separator);
}
Error:
Exception in thread "pool-3-thread-18" java.lang.NullPointerException at edp.core.utils.FileUtils.deleteDir(FileUtils.java:185) at edp.davinci.schedule.SystemSchedule.lambda$clearTempDir$0(SystemSchedule.java:75) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)