-
Notifications
You must be signed in to change notification settings - Fork 459
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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.
if (keystoreFile.exists()) { | ||
if (!keystoreFile.delete()) { | ||
log.error("Unable to delete {}", keystoreFile); | ||
} | ||
} |
There was a problem hiding this comment.
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.
Map<String,String> contents = ClusterConfigParser | ||
.parseConfiguration(Path.of(configFile.toURI()).toFile().getAbsolutePath()); | ||
.parseConfiguration(Path.of(configFile.toURI()).toAbsolutePath().toString()); |
There was a problem hiding this comment.
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.
No description provided.