Skip to content

Commit

Permalink
Merge pull request #6871 from Viii3/FISH-9176-Spotbugs
Browse files Browse the repository at this point in the history
FISH-9176 FISH-9193 FISH-9194 FISH-9195 Improvements from Spotbugs
  • Loading branch information
Viii3 authored Aug 15, 2024
2 parents 048760e + 819e907 commit 354c20e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
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

0 comments on commit 354c20e

Please sign in to comment.