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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

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.

return file.getAbsolutePath();
Path path = Path.of(keystorePath);
if (Files.exists(path)) {
return path.toAbsolutePath().toString();
Copy link
Member

Choose a reason for hiding this comment

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

This is a private method. It can return the absolute path without converting it to a string. The calling code can keep it as a path or convert it as needed. That reduces the assumptions this code makes on how it is used by the callers.

Comment on lines 156 to 160
if (keystoreFile.exists()) {
if (!keystoreFile.delete()) {
log.error("Unable to delete {}", keystoreFile);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused why the file deletion was removed from these changes. It seems like the file is supposed to get re-created, or something, and this cleaned up the old one if it existed from a previous build. My guess is that behavior is still desired.

Comment on lines 294 to 295
Map<String,String> contents = ClusterConfigParser
.parseConfiguration(Path.of(configFile.toURI()).toFile().getAbsolutePath());
.parseConfiguration(Path.of(configFile.toURI()).toAbsolutePath().toString());
Copy link
Member

Choose a reason for hiding this comment

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

ClusterConfigParser could take a Path object instead of a String. That would simplify this further, and make it more type-safe. ClusterConfigParser is only used internally.

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.

2 participants