Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ public Answer forgetObject(ForgetObjectCmd cmd) {
}

private static String deriveTemplateUuidOnHost(VmwareHypervisorHost hyperHost, String storeIdentifier, String templateName) {
String templateUuid = UUID.nameUUIDFromBytes((templateName + "@" + storeIdentifier + "-" + hyperHost.getMor().getValue()).getBytes()).toString();
String templateUuid = UUID.nameUUIDFromBytes((templateName + "@" + storeIdentifier + "-" + hyperHost.getMor().getValue()).getBytes("UTF-8")).toString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In other cases I used Charset.defaultCharset(). Is there a reason to explicitly use "UTF8"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@DaanHoogland
Unless you're getting platform specifc data, i think it's best to always stick to use the same charset, to avoid different values from being generated in different platforms whenever possible. Ideally, we should convert all data that comes into the application to a standard charset that supports internationalization such as UTF-8, and just use default platform charset where applicable, when consuming data from platform specific sources.
Using Charset.defaultCharset() will require an extra import and increase the overall size of the class, altough instantiating a String also has its own overhead, i believe it to be less so.. we can also remove string instantiation at runtime by defining a constant, which will also increase runtime efficiency.
Of course this is only my point of view, please comment if you feel otherwise :)

templateUuid = templateUuid.replaceAll("-", "");
return templateUuid;
}
Expand Down