From f1149bcb09e88b1aeeeb78ef011e09dc1e2f0649 Mon Sep 17 00:00:00 2001 From: Xia Li <47727869+bd2019us@users.noreply.github.com> Date: Thu, 30 Jan 2020 05:06:15 -0600 Subject: [PATCH] =?UTF-8?q?[CLOUDSTACK-10408]=20Fix=20String.replaceAll()?= =?UTF-8?q?=20to=20replace()=20for=20bet=E2=80=A6=20(#3275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [CLOUDSTACK-10408] Fix String.replaceAll() to replace() for better performance * improve with replace char but string Co-authored-by: Rohit Yadav --- .../framework/serializer/OnwireClassRegistry.java | 4 ++-- .../hypervisor/kvm/resource/LibvirtComputingResource.java | 2 +- .../hypervisor/vmware/manager/VmwareStorageManagerImpl.java | 4 ++-- server/src/main/java/com/cloud/user/AccountManagerImpl.java | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/ipc/src/main/java/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java b/framework/ipc/src/main/java/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java index de7558734c3..24ccfe42afc 100644 --- a/framework/ipc/src/main/java/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java +++ b/framework/ipc/src/main/java/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java @@ -109,7 +109,7 @@ public class OnwireClassRegistry { if (filePath != null) { // WINDOWS HACK if (filePath.indexOf("%20") > 0) - filePath = filePath.replaceAll("%20", " "); + filePath = filePath.replace("%20", " "); if ((filePath.indexOf("!") > 0) && (filePath.indexOf(".jar") > 0)) { String jarPath = filePath.substring(0, filePath.indexOf("!")).substring(filePath.indexOf(":") + 1); // WINDOWS HACK @@ -183,4 +183,4 @@ public class OnwireClassRegistry { static String stripFilenameExtension(String file) { return file.substring(0, file.lastIndexOf('.')); } -} \ No newline at end of file +} diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 76db243ee6b..47d5aade36b 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -2979,7 +2979,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv final int vnetId = Integer.parseInt(nic.getBrName().replaceFirst("cloudVirBr", "")); final String pifName = getPif(_guestBridgeName); final String newBrName = "br" + pifName + "-" + vnetId; - vmDef = vmDef.replaceAll("'" + nic.getBrName() + "'", "'" + newBrName + "'"); + vmDef = vmDef.replace("'" + nic.getBrName() + "'", "'" + newBrName + "'"); s_logger.debug("VM bridge name is changed from " + nic.getBrName() + " to " + newBrName); } catch (final NumberFormatException e) { continue; diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java index 97b5088ccae..f17d613125c 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java @@ -525,7 +525,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { String details = null; boolean success = false; - String newVolumeName = UUID.randomUUID().toString().replaceAll("-", ""); + String newVolumeName = UUID.randomUUID().toString().replace("-", ""); VmwareContext context = hostService.getServiceContext(cmd); try { @@ -1053,7 +1053,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { Integer nfsVersion) throws Exception { String volumeFolder = String.valueOf(volumeId) + "/"; - String newVolume = UUID.randomUUID().toString().replaceAll("-", ""); + String newVolume = UUID.randomUUID().toString().replace("-", ""); restoreVolumeFromSecStorage(hyperHost, dsMo, newVolume, secStorageUrl, "volumes/" + volumeFolder, exportName, nfsVersion); return new Pair(volumeFolder, newVolume); diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java index 20d769f09ef..6ef30ebc69f 100644 --- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java +++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java @@ -2328,9 +2328,9 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // Block when is not in the list of allowed IPs if (!NetUtils.isIpInCidrList(loginIpAddress, accessAllowedCidrs.split(","))) { - s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replaceAll("/", "") + " does not match " + accessAllowedCidrs); + s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replace("/", "") + " does not match " + accessAllowedCidrs); throw new CloudAuthenticationException("Failed to authenticate user '" + username + "' in domain '" + domain.getPath() + "' from ip " - + loginIpAddress.toString().replaceAll("/", "") + "; please provide valid credentials"); + + loginIpAddress.toString().replace("/", "") + "; please provide valid credentials"); } } @@ -2912,4 +2912,4 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M public ConfigKey[] getConfigKeys() { return new ConfigKey[] {UseSecretKeyInResponse}; } -} \ No newline at end of file +}