Skip to content

[Chore][Common] Handle parentless paths in FileUtils#18408

Open
hiSandog wants to merge 1 commit into
apache:devfrom
hiSandog:fix/small-cleanup-20260710
Open

[Chore][Common] Handle parentless paths in FileUtils#18408
hiSandog wants to merge 1 commit into
apache:devfrom
hiSandog:fix/small-cleanup-20260710

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

Was this PR generated or assisted by AI?

YES. The implementation and regression test were assisted by Codex.

Purpose of the pull request

FileUtils.writeContent2File dereferences getParentFile() unconditionally. A valid relative filename such as output.txt has no parent component, so the method throws a NullPointerException instead of writing the file.

Brief change log

  • Guard parent-directory creation when the destination has no parent component.
  • Add a regression test that writes and cleans up a parentless relative path.

Verify this pull request

This change added tests and was verified as follows:

  • ./mvnw -q -pl dolphinscheduler-common -Dlombok.version=1.18.36 -Dspotless.skip=true -Dtest=FileUtilsTest test (9 tests passed; overrides only adapt the local JDK 21 environment)
  • ./mvnw -q -pl dolphinscheduler-common -Dspotless.version=2.44.3 -DspotlessFiles='src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java,src/test/java/org/apache/dolphinscheduler/common/utils/FileUtilsTest.java' spotless:check
  • git diff --check upstream/dev...HEAD

Pull Request Notice

Pull Request Notice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant