Skip to content

Simplify conversions from java.nio.file.Path to File #5547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 6, 2025

Conversation

DomGarguilo
Copy link
Member

No description provided.

@DomGarguilo DomGarguilo added this to the 4.0.0 milestone May 12, 2025
@DomGarguilo DomGarguilo self-assigned this May 12, 2025
Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these changes are nice. There is some potential to move further away from String-types in some of the method return types and parameter types, to improve type safety.

@DomGarguilo DomGarguilo marked this pull request as ready for review May 29, 2025 18:14
@DomGarguilo
Copy link
Member Author

I've marked this as ready for review. I've gone through all the places that call .toFile() or otherwise could be simplified to reduce converting to/from a File object and opted to use Path instead where it made sense.

Copy link
Member

@kevinrr888 kevinrr888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't finished reviewing, I'll finish on Monday. Posting my comments so far, most comments are repeats

It would be good to run the full set of tests for this PR as well.

@DomGarguilo
Copy link
Member Author

@kevinrr888 i pushed up 9891482 to address some of your comments.

Regarding all the comments suggesting to assertTrue(Files.isDirectory(dir)) or similar with a file, Files.isDirectory will throw an exception if it does not properly create a directory at the given path. So in most (if not all) cases here, we can rely on that exception to alert us about any failure and if no exception is thrown, we can safely assume that things were created properly. Same goes for the Files.createFile()

@kevinrr888
Copy link
Member

Regarding all the comments suggesting to assertTrue(Files.isDirectory(dir)) or similar with a file, Files.isDirectory will throw an exception if it does not properly create a directory at the given path. So in most (if not all) cases here, we can rely on that exception to alert us about any failure and if no exception is thrown, we can safely assume that things were created properly. Same goes for the Files.createFile()

Ah I see, feel free to resolve all those comments.
I remember seeing places where you do include the assertion assertTrue(Files.isDirectory(dir)) after the creation, which is why I thought we should be ensuring it actually exists. Maybe could remove those assertions?

testDir = baseDir.resolve(MiniAccumuloClusterTest.class.getName()).toFile();
FileUtils.deleteQuietly(testDir);
assertTrue(testDir.mkdir());
Path testDir = tempDir.resolve(MiniAccumuloClusterTest.class.getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be MiniAccumuloClusterClasspathTest?

Copy link
Member

@kevinrr888 kevinrr888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes LGTM so long as the full set of tests pass

@DomGarguilo DomGarguilo merged commit 2335a44 into apache:main Jun 6, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants