Skip to content

Commit f1149bc

Browse files
bd2019usyadvr
andauthored
[CLOUDSTACK-10408] Fix String.replaceAll() to replace() for bet… (#3275)
* [CLOUDSTACK-10408] Fix String.replaceAll() to replace() for better performance * improve with replace char but string Co-authored-by: Rohit Yadav <rohit@apache.org>
1 parent 99ec8a8 commit f1149bc

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

framework/ipc/src/main/java/org/apache/cloudstack/framework/serializer/OnwireClassRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static Set<Class<?>> getClasses(ClassLoader loader, String packageName) {
109109
if (filePath != null) {
110110
// WINDOWS HACK
111111
if (filePath.indexOf("%20") > 0)
112-
filePath = filePath.replaceAll("%20", " ");
112+
filePath = filePath.replace("%20", " ");
113113
if ((filePath.indexOf("!") > 0) && (filePath.indexOf(".jar") > 0)) {
114114
String jarPath = filePath.substring(0, filePath.indexOf("!")).substring(filePath.indexOf(":") + 1);
115115
// WINDOWS HACK
@@ -183,4 +183,4 @@ static Set<Class<?>> getFromJARFile(String jar, String packageName) throws IOExc
183183
static String stripFilenameExtension(String file) {
184184
return file.substring(0, file.lastIndexOf('.'));
185185
}
186-
}
186+
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2979,7 +2979,7 @@ public String rebootVM(final Connect conn, final String vmName) {
29792979
final int vnetId = Integer.parseInt(nic.getBrName().replaceFirst("cloudVirBr", ""));
29802980
final String pifName = getPif(_guestBridgeName);
29812981
final String newBrName = "br" + pifName + "-" + vnetId;
2982-
vmDef = vmDef.replaceAll("'" + nic.getBrName() + "'", "'" + newBrName + "'");
2982+
vmDef = vmDef.replace("'" + nic.getBrName() + "'", "'" + newBrName + "'");
29832983
s_logger.debug("VM bridge name is changed from " + nic.getBrName() + " to " + newBrName);
29842984
} catch (final NumberFormatException e) {
29852985
continue;

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCom
525525

526526
String details = null;
527527
boolean success = false;
528-
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
528+
String newVolumeName = UUID.randomUUID().toString().replace("-", "");
529529

530530
VmwareContext context = hostService.getServiceContext(cmd);
531531
try {
@@ -1053,7 +1053,7 @@ private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyper
10531053
Integer nfsVersion) throws Exception {
10541054

10551055
String volumeFolder = String.valueOf(volumeId) + "/";
1056-
String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
1056+
String newVolume = UUID.randomUUID().toString().replace("-", "");
10571057
restoreVolumeFromSecStorage(hyperHost, dsMo, newVolume, secStorageUrl, "volumes/" + volumeFolder, exportName, nfsVersion);
10581058

10591059
return new Pair<String, String>(volumeFolder, newVolume);

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,9 +2328,9 @@ public UserAccount authenticateUser(final String username, final String password
23282328

23292329
// Block when is not in the list of allowed IPs
23302330
if (!NetUtils.isIpInCidrList(loginIpAddress, accessAllowedCidrs.split(","))) {
2331-
s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replaceAll("/", "") + " does not match " + accessAllowedCidrs);
2331+
s_logger.warn("Request by account '" + account.toString() + "' was denied since " + loginIpAddress.toString().replace("/", "") + " does not match " + accessAllowedCidrs);
23322332
throw new CloudAuthenticationException("Failed to authenticate user '" + username + "' in domain '" + domain.getPath() + "' from ip "
2333-
+ loginIpAddress.toString().replaceAll("/", "") + "; please provide valid credentials");
2333+
+ loginIpAddress.toString().replace("/", "") + "; please provide valid credentials");
23342334
}
23352335
}
23362336

@@ -2912,4 +2912,4 @@ public String getConfigComponentName() {
29122912
public ConfigKey<?>[] getConfigKeys() {
29132913
return new ConfigKey<?>[] {UseSecretKeyInResponse};
29142914
}
2915-
}
2915+
}

0 commit comments

Comments
 (0)