This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 39f6838d0 [Bug] PluginLoader localDirs cause PluginLoader error (#960)
39f6838d0 is described below
commit 39f6838d0a26af9085c81a18d553f2ff5b77e033
Author: Jingsong Lee <[email protected]>
AuthorDate: Thu Apr 20 17:13:38 2023 +0800
[Bug] PluginLoader localDirs cause PluginLoader error (#960)
---
.../org/apache/paimon/plugin/PluginLoader.java | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git
a/paimon-common/src/main/java/org/apache/paimon/plugin/PluginLoader.java
b/paimon-common/src/main/java/org/apache/paimon/plugin/PluginLoader.java
index 4de375e60..2270e4a07 100644
--- a/paimon-common/src/main/java/org/apache/paimon/plugin/PluginLoader.java
+++ b/paimon-common/src/main/java/org/apache/paimon/plugin/PluginLoader.java
@@ -20,7 +20,9 @@ package org.apache.paimon.plugin;
import org.apache.paimon.utils.IOUtils;
import org.apache.paimon.utils.LocalFileUtils;
+import org.apache.paimon.utils.StringUtils;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -30,6 +32,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import java.util.ServiceLoader;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -63,11 +66,9 @@ public class PluginLoader {
public PluginLoader(String jarName) {
try {
ClassLoader ownerClassLoader = PluginLoader.class.getClassLoader();
- String localDirs = System.getenv("LOCAL_DIRS");
- if (null == localDirs || "".equals(localDirs)) {
- localDirs = System.getProperty("java.io.tmpdir");
- }
- Path tmpDirectory = Paths.get(localDirs);
+ Path tmpDirectory =
+ tmpDirectoryFromYarn()
+ .orElseGet(() ->
Paths.get(System.getProperty("java.io.tmpdir")));
Files.createDirectories(
LocalFileUtils.getTargetPathIfContainsSymbolicPath(tmpDirectory));
Path delegateJar =
@@ -137,4 +138,15 @@ public class PluginLoader {
public ClassLoader submoduleClassLoader() {
return submoduleClassLoader;
}
+
+ private static Optional<Path> tmpDirectoryFromYarn() {
+ String localDirs = System.getenv("LOCAL_DIRS");
+ if (!StringUtils.isBlank(localDirs)) {
+ String[] paths = localDirs.split(",|" + File.pathSeparator);
+ if (paths.length > 0) {
+ return Optional.of(Paths.get(paths[0]));
+ }
+ }
+ return Optional.empty();
+ }
}