From 6644abd5f7c4ff9049a43a72212cd20d446e97d7 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Wed, 19 Jun 2024 14:32:21 +0800 Subject: [PATCH] Fix HdfsStorageOperatorTest NPE (#16178) --- .../plugin/storage/hdfs/LocalStorageOperatorTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java b/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java index c90500c343..7a277afbce 100644 --- a/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java +++ b/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/test/java/org/apache/dolphinscheduler/plugin/storage/hdfs/LocalStorageOperatorTest.java @@ -27,9 +27,6 @@ import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity; import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator; import org.apache.dolphinscheduler.spi.enums.ResourceType; -import org.apache.commons.lang3.StringUtils; - -import java.io.File; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Paths; @@ -45,8 +42,8 @@ class LocalStorageOperatorTest { private StorageOperator storageOperator; - private static final String resourceBaseDir = StringUtils - .substringBeforeLast(FileUtils.getClassPathAbsolutePath(LocalStorageOperatorTest.class), File.separator); + private static final String resourceBaseDir = + Paths.get(LocalStorageOperatorTest.class.getResource("/").getFile(), "localStorage").toString(); private static final String tenantCode = "default"; private static final String baseDir = Paths.get(resourceBaseDir, tenantCode, Constants.RESOURCE_TYPE_FILE).toString(); @@ -54,6 +51,7 @@ class LocalStorageOperatorTest { @SneakyThrows @BeforeEach public void setup() { + Files.createDirectories(Paths.get(resourceBaseDir)); System.setProperty(Constants.RESOURCE_UPLOAD_PATH, resourceBaseDir); LocalStorageOperatorFactory localStorageOperatorFactory = new LocalStorageOperatorFactory();