hiSandog opened a new issue, #18562:
URL: https://github.com/apache/dolphinscheduler/issues/18562
### Search before asking
- [x] I searched the existing issues and found no similar report.
### What happened
`FileUtils.writeContent2File` fails when `filePath` is a valid filename
without a parent component, such as `output.txt`.
The method calls `distFile.getParentFile().exists()` unconditionally. For a
parentless relative path, `File.getParentFile()` returns `null`, so the method
throws a `NullPointerException` before it can create the file.
### What you expected to happen
`FileUtils.writeContent2File("test content", "output.txt")` should write the
file in the current working directory and return `true`.
### How to reproduce
On the `dev` branch, call:
```java
FileUtils.writeContent2File("test content", "output.txt");
```
The call dereferences the null result of `getParentFile()` and fails before
opening the output stream.
### Anything else
The parent directory should only be checked or created when
`getParentFile()` is non-null. A proposed fix and regression test are available
in #18408.
### Version
dev
### Are you willing to submit PR?
- [x] Yes, I am willing to submit a PR.
### Code of Conduct
- [x] I agree to follow the project's Code of Conduct.
--
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]