justinmclean opened a new issue, #8052:
URL: https://github.com/apache/gravitino/issues/8052

   ### What would you like to be improved?
   
   The working directory should be derived from an absolute executable path, 
ensuring a non-null parent directory even when the path lacks a parent 
component.
   
   Here's a unit test showing the issue:
   ```
   @Test
     public void testExecutableWithoutParent(@TempDir Path tempDir) throws 
Exception {
       Path script = tempDir.resolve("script.sh");
       Files.write(script, Arrays.asList("#!/bin/bash", "echo hello"), 
StandardCharsets.UTF_8);
   
       String originalUserDir = System.getProperty("user.dir");
       System.setProperty("user.dir", tempDir.toString());
       try {
         ShellJobTemplate template =
             ShellJobTemplate.builder()
                 .withName("test")
                 .withExecutable("script.sh")
                 .withArguments(Collections.emptyList())
                 .withEnvironments(Collections.emptyMap())
                 .withScripts(Collections.emptyList())
                 .build();
   
         Process process =
             LocalProcessBuilder.create(template, 
Collections.emptyMap()).start();
         process.waitFor(5, TimeUnit.SECONDS);
   
         File output = tempDir.resolve("output.log").toFile();
         Assertions.assertTrue(output.exists());
         String out = new String(Files.readAllBytes(output.toPath()), 
StandardCharsets.UTF_8);
         Assertions.assertTrue(out.contains("hello"));
       } finally {
         System.setProperty("user.dir", originalUserDir);
       }
     }
   ```
   
   ### How should we improve?
   
   Use getAbsoluteFile().getParentFile()


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to