Skip to content

Commit

Permalink
Merge branch 'apache:trunk' into HDFS-16016
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 authored Jan 17, 2024
2 parents a25f1e5 + 9634bd3 commit 70583a0
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
Expand Down Expand Up @@ -287,20 +291,18 @@ public void run(String[] args) throws Throwable {

final File workDir;
try {
workDir = File.createTempFile("hadoop-unjar", "", tmpDir);
} catch (IOException ioe) {
FileAttribute<Set<PosixFilePermission>> perms = PosixFilePermissions
.asFileAttribute(PosixFilePermissions.fromString("rwx------"));
workDir = Files.createTempDirectory(tmpDir.toPath(), "hadoop-unjar", perms).toFile();
} catch (IOException | SecurityException e) {
// If user has insufficient perms to write to tmpDir, default
// "Permission denied" message doesn't specify a filename.
System.err.println("Error creating temp dir in java.io.tmpdir "
+ tmpDir + " due to " + ioe.getMessage());
+ tmpDir + " due to " + e.getMessage());
System.exit(-1);
return;
}

if (!workDir.delete()) {
System.err.println("Delete failed for " + workDir);
System.exit(-1);
}
ensureDirectory(workDir);

ShutdownHookManager.get().addShutdownHook(
Expand Down

0 comments on commit 70583a0

Please sign in to comment.