Skip to content
Merged
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 @@ -4266,7 +4266,11 @@ public void setBackingFileFormat(String volPath) {
Map<String, String> info = qemu.info(file);
String backingFilePath = info.get(new String("backing_file"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I detect that this code is problematic. According to the Performance (PERFORMANCE), Dm: Method invokes inefficient new String(String) constructor (DM_STRING_CTOR).
Using the java.lang.String(String) constructor wastes memory because the object so constructed will be functionally indistinguishable from the String passed as a parameter.  Just use the argument String directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rubieHess good point. thanks ! I will create a pr for it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Happy to help.

String backingFileFormat = info.get(new String("backing_file_format"));
if (org.apache.commons.lang.StringUtils.isEmpty(backingFileFormat)) {
if (org.apache.commons.lang.StringUtils.isNotBlank(backingFilePath)
&& org.apache.commons.lang.StringUtils.isBlank(backingFileFormat)) {
// VMs which are created in CloudStack 4.14 and before cannot be started or migrated
// in latest Linux distributions due to missing backing file format
// Please refer to https://libvirt.org/kbase/backing_chains.html#vm-refuses-to-start-due-to-misconfigured-backing-store-format
s_logger.info("Setting backing file format of " + volPath);
QemuImgFile backingFile = new QemuImgFile(backingFilePath);
Map<String, String> backingFileinfo = qemu.info(backingFile);
Expand Down