Skip to content
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

FISH-9176 FISH-9193 FISH-9194 FISH-9195 Improvements from Spotbugs #6871

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
/*
* Copyright (c) [2016-2024] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -164,13 +164,14 @@ public static void sendAsadminCommandToSelectedInstances(HandlerContext handlerC
command = splitCommand[0];

// Convert the parameters into a space-separated string
String parameters = "";
String parameters;
StringBuilder paramBuilder = new StringBuilder();
for (int i = 1; i < splitCommand.length; i++) {
parameters += splitCommand[i] + " ";
paramBuilder.append(splitCommand[i]).append(" ");
}

// Remove any trailing spaces
parameters = parameters.trim();
parameters = paramBuilder.toString().trim();

// Get the parameters from each row, and send the asadmin command
for (Map row : selectedRows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2019] Payara Foundation and/or affiliates
// Portions Copyright [2024] Payara Foundation and/or affiliates

package org.glassfish.admin.rest.readers;

Expand Down Expand Up @@ -112,7 +112,7 @@ public double getDouble(String key) throws InputException {
try {
return o instanceof Number ?
((Number)o).doubleValue() :
Double.valueOf((String) o);
Double.parseDouble((String) o);
} catch (Exception e) {
throw new InputException("InputObject[" + quote(key) +
"] is not a number.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2016-2021 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2024 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -107,12 +107,12 @@ public void event(Event event) {

private String constructAsadminCommand(String commandName, ParameterMap parameters) {

String asadminCommand = commandName;
String mandatoryOption = "";
StringBuilder asadminCommand = new StringBuilder(commandName);
StringBuilder mandatoryOption = new StringBuilder();

if (Boolean.parseBoolean(asadminRecorderConfiguration.prependEnabled()) && prependedOptions != null) {
for (String s : prependedOptions) {
asadminCommand += " " + s;
asadminCommand.append(" ").append(s);
}
}

Expand All @@ -123,21 +123,21 @@ private String constructAsadminCommand(String commandName, ParameterMap paramete
// This can have sub-parameters, so loop through and add spaces
// between the sub-parameters.
for (int i = 0; i < parameter.getValue().size(); i++) {
mandatoryOption += parameter.getValue().get(i);
mandatoryOption.append(parameter.getValue().get(i));
if (i != (parameter.getValue().size() - 1)) {
mandatoryOption += " ";
mandatoryOption.append(" ");
}
}
} else {
asadminCommand += " --" + parameter.getKey() + "=" + parameter.getValue().get(0);
asadminCommand.append(" --").append(parameter.getKey()).append("=").append(parameter.getValue().get(0));
}
}
}

asadminCommand += " " + mandatoryOption;
asadminCommand += "\n";
asadminCommand.append(" ").append(mandatoryOption);
asadminCommand.append("\n");

return asadminCommand;
return asadminCommand.toString();
}

/**
Expand Down