diff --git a/appserver/tests/admin/ssh-cluster/pom.xml b/appserver/tests/admin/ssh-cluster/pom.xml
index 032e0b5b821..414324346cd 100644
--- a/appserver/tests/admin/ssh-cluster/pom.xml
+++ b/appserver/tests/admin/ssh-cluster/pom.xml
@@ -21,7 +21,7 @@
org.glassfish.main.tests
admin-tests-parent
- 7.0.21-SNAPSHOT
+ 7.0.22-SNAPSHOT
ssh-cluster-tests
diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/JvmOptionsHelper.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/JvmOptionsHelper.java
index 9e6ab27e66f..bf5bc28f557 100644
--- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/JvmOptionsHelper.java
+++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/JvmOptionsHelper.java
@@ -78,13 +78,13 @@ public String[] addJvmOptions(String[] options) throws InvalidJvmOptionException
}
final Set alreadyExist = new HashSet();
JvmOptionsElement last = last();
- for (int i = 0; i < options.length; i++) {
- if (!head.hasOption(options[i])) {
- JvmOptionsElement x = new JvmOptionsElement(options[i]);
+ for (String option : options) {
+ if (!head.hasOption(option)) {
+ JvmOptionsElement x = new JvmOptionsElement(option);
last.setNext(x);
last = x;
} else {
- alreadyExist.add(options[i]);
+ alreadyExist.add(option);
}
}
return toStringArray(alreadyExist);
@@ -115,9 +115,9 @@ public String[] deleteJvmOptions(String[] options) {
}
final Set donotExist = new HashSet();
- for (int i = 0; i < options.length; i++) {
- if (!head.deleteJvmOption(options[i])) {
- donotExist.add(options[i]);
+ for (String option : options) {
+ if (!head.deleteJvmOption(option)) {
+ donotExist.add(option);
}
}
return toStringArray(donotExist);
@@ -209,6 +209,7 @@ void setNext(JvmOptionsElement element) {
throw new UnsupportedOperationException();
}
};
+
private final Set jvmOptions = new LinkedHashSet();
private JvmOptionsElement next;
diff --git a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/CreateNodeConfigCommand.java b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/CreateNodeConfigCommand.java
index bceadb2c04e..e519d9df982 100644
--- a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/CreateNodeConfigCommand.java
+++ b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/CreateNodeConfigCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -24,6 +25,7 @@
import jakarta.inject.Inject;
import java.io.File;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
@@ -86,15 +88,12 @@ public void execute(AdminCommandContext context) {
TokenResolver resolver = null;
// Create a resolver that can replace system properties in strings
- Map systemPropsMap =
- new HashMap((Map)(System.getProperties()));
+ Map systemPropsMap = new HashMap((Map) (System.getProperties()));
resolver = new TokenResolver(systemPropsMap);
- String resolvedInstallDir = resolver.resolve(installdir);
- File actualInstallDir = new File( resolvedInstallDir+"/" + NodeUtils.LANDMARK_FILE);
-
-
- if (!actualInstallDir.exists()){
- report.setMessage(Strings.get("invalid.installdir",installdir));
+ Path resolvedInstallDir = new File(resolver.resolve(installdir)).toPath();
+ Path actualInstallDir = resolvedInstallDir.resolve(NodeUtils.LANDMARK_FILE);
+ if (!actualInstallDir.toFile().exists()) {
+ report.setMessage(Strings.get("invalid.installdir", installdir));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
@@ -103,12 +102,15 @@ public void execute(AdminCommandContext context) {
CommandInvocation ci = cr.getCommandInvocation("_create-node", report, context.getSubject());
ParameterMap map = new ParameterMap();
map.add("DEFAULT", name);
- if (StringUtils.ok(nodedir))
+ if (StringUtils.ok(nodedir)) {
map.add(NodeUtils.PARAM_NODEDIR, nodedir);
- if (StringUtils.ok(installdir))
+ }
+ if (StringUtils.ok(installdir)) {
map.add(NodeUtils.PARAM_INSTALLDIR, installdir);
- if (StringUtils.ok(nodehost))
+ }
+ if (StringUtils.ok(nodehost)) {
map.add(NodeUtils.PARAM_NODEHOST, nodehost);
+ }
map.add(NodeUtils.PARAM_TYPE,"CONFIG");
ci.parameters(map);
ci.execute();
diff --git a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/UpdateNodeCommand.java b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/UpdateNodeCommand.java
index 67a3b516cc4..1fab305f3ee 100644
--- a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/UpdateNodeCommand.java
+++ b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/UpdateNodeCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -29,6 +30,7 @@
import java.beans.PropertyVetoException;
import java.io.File;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
@@ -99,20 +101,20 @@ public class UpdateNodeCommand implements AdminCommand {
@Param(name="sshnodehost", optional=true)
String sshnodehost;
- @Param(name="sshkeyfile", optional=true)
+ @Param(name = "sshkeyfile", optional = true)
String sshkeyfile;
- @Param(name = "sshpassword", optional = true, password=true)
- String sshpassword;
+ @Param(name = "sshpassword", optional = true, password = true)
+ String sshpassword;
- @Param(name = "sshkeypassphrase", optional = true, password=true)
- String sshkeypassphrase;
+ @Param(name = "sshkeypassphrase", optional = true, password = true)
+ String sshkeypassphrase;
@Param(name = "windowsdomain", optional = true)
- String windowsdomain;
+ String windowsdomain;
- @Param(name = "type", optional=true)
- String type;
+ @Param(name = "type", optional = true)
+ String type;
@Override
public void execute(AdminCommandContext context) {
@@ -134,15 +136,12 @@ public void execute(AdminCommandContext context) {
TokenResolver resolver = null;
// Create a resolver that can replace system properties in strings
- Map systemPropsMap =
- new HashMap((Map)(System.getProperties()));
+ Map systemPropsMap = new HashMap((Map) (System.getProperties()));
resolver = new TokenResolver(systemPropsMap);
- String resolvedInstallDir = resolver.resolve(installdir);
- File actualInstallDir = new File( resolvedInstallDir+"/" + NodeUtils.LANDMARK_FILE);
-
-
- if (!actualInstallDir.exists()){
- report.setMessage(Strings.get("invalid.installdir",installdir));
+ Path resolvedInstallDir = new File(resolver.resolve(installdir)).toPath();
+ Path actualInstallDir = resolvedInstallDir.resolve(NodeUtils.LANDMARK_FILE);
+ if (!actualInstallDir.toFile().exists()) {
+ report.setMessage(Strings.get("invalid.installdir", installdir));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
@@ -195,43 +194,56 @@ public Object run(ConfigBeanProxy param) throws PropertyVetoException, Transacti
Nodes nodes = ((Domain)param).getNodes();
Node node = nodes.getNode(nodeName);
Node writeableNode = t.enroll(node);
- if (windowsdomain != null)
+ if (windowsdomain != null) {
writeableNode.setWindowsDomain(windowsdomain);
- if (nodedir != null)
+ }
+ if (nodedir != null) {
writeableNode.setNodeDir(nodedir);
- if (nodehost != null)
+ }
+ if (nodehost != null) {
writeableNode.setNodeHost(nodehost);
- if (installdir != null)
+ }
+ if (installdir != null) {
writeableNode.setInstallDir(installdir);
- if (type != null)
+ }
+ if (type != null) {
writeableNode.setType(type);
+ }
if (sshport != null || sshnodehost != null ||sshuser != null || sshkeyfile != null){
SshConnector sshC = writeableNode.getSshConnector();
if (sshC == null) {
sshC =writeableNode.createChild(SshConnector.class);
- }else
+ } else {
sshC = t.enroll(sshC);
+ }
- if (sshport != null)
+ if (sshport != null) {
sshC.setSshPort(sshport);
- if(sshnodehost != null)
+ }
+ if(sshnodehost != null) {
sshC.setSshHost(sshnodehost);
+ }
if (sshuser != null || sshkeyfile != null || sshpassword != null || sshkeypassphrase != null ) {
SshAuth sshA = sshC.getSshAuth();
if (sshA == null) {
sshA = sshC.createChild(SshAuth.class);
- } else
+ } else {
sshA = t.enroll(sshA);
+ }
- if (sshuser != null)
+ if (sshuser != null) {
sshA.setUserName(sshuser);
- if (sshkeyfile != null)
+ }
+ if (sshkeyfile != null) {
sshA.setKeyfile(sshkeyfile);
- if(sshpassword != null)
+ }
+ if(sshpassword != null) {
sshA.setPassword(sshpassword);
- if(sshkeypassphrase != null)
+ }
+ if(sshkeypassphrase != null) {
sshA.setKeyPassphrase(sshkeypassphrase);
+ }
sshC.setSshAuth(sshA);
}
writeableNode.setSshConnector(sshC);
diff --git a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/CreateLocalInstanceFilesystemCommand.java b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/CreateLocalInstanceFilesystemCommand.java
index 008f4396c23..a5916af4dc6 100644
--- a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/CreateLocalInstanceFilesystemCommand.java
+++ b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/CreateLocalInstanceFilesystemCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -13,7 +14,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-
package com.sun.enterprise.admin.cli.cluster;
import com.sun.enterprise.util.net.NetUtils;
@@ -70,10 +70,11 @@ public class CreateLocalInstanceFilesystemCommand extends LocalInstanceCommand {
protected void validate()
throws CommandException {
- if(ok(instanceName0))
+ if (ok(instanceName0)) {
instanceName = instanceName0;
- else
+ } else {
throw new CommandException(Strings.get("Instance.badInstanceName"));
+ }
isCreateInstanceFilesystem = true;
@@ -108,8 +109,6 @@ protected void validate()
}
- /**
- */
@Override
protected int executeCommand()
throws CommandException {
@@ -188,17 +187,15 @@ private void checkDASCoordinates() throws CommandException {
InetAddress.getByName(DASHost);
} catch (UnknownHostException e) {
String thisHost = NetUtils.getHostName();
- String msg = Strings.get("Instance.DasHostUnknown",
- DASHost, thisHost);
+ String msg = Strings.get("Instance.DasHostUnknown", DASHost, thisHost);
throw new CommandException(msg, e);
}
// See if DAS is reachable
- if (! NetUtils.isRunning(DASHost, DASPort)) {
+ if (!NetUtils.isRunning(DASHost, DASPort)) {
// DAS provided host and port
String thisHost = NetUtils.getHostName();
- String msg = Strings.get("Instance.DasHostUnreachable",
- DASHost, Integer.toString(DASPort), thisHost);
+ String msg = Strings.get("Instance.DasHostUnreachable", DASHost, Integer.toString(DASPort), thisHost);
throw new CommandException(msg);
}
}
diff --git a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/InstallNodeBaseCommand.java b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/InstallNodeBaseCommand.java
index 9150e483198..14be18425b5 100644
--- a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/InstallNodeBaseCommand.java
+++ b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/InstallNodeBaseCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -34,7 +35,6 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import java.util.logging.Level;
import org.glassfish.api.Param;
import org.glassfish.api.admin.CommandException;
@@ -43,6 +43,8 @@
import org.glassfish.internal.api.Globals;
import org.jvnet.hk2.annotations.Service;
+import static java.util.logging.Level.FINER;
+
/**
* @author Rajiv Mordani
* @author Byron Nevins
@@ -83,24 +85,21 @@ protected void validate() throws CommandException {
@Override
protected int executeCommand() throws CommandException {
File zipFile = null;
-
try {
- ArrayList binDirFiles = new ArrayList();
+ ArrayList binDirFiles = new ArrayList<>();
precopy();
zipFile = createZipFileIfNeeded(binDirFiles);
copyToHosts(zipFile, binDirFiles);
- }
- catch (CommandException e) {
+ } catch (CommandException e) {
throw e;
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new CommandException(e);
- }
- finally {
+ } finally {
if (!save && delete) {
if (zipFile != null) {
- if (!zipFile.delete())
+ if (!zipFile.delete()) {
zipFile.deleteOnExit();
+ }
}
}
}
@@ -128,31 +127,28 @@ private File createZipFileIfNeeded(ArrayList binDirFiles) throws IOExcep
File zipFileLocation = null;
File glassFishZipFile = null;
- if (archive != null) {
+ if (archive == null) {
+ zipFileLocation = new File(".");
+ if (!zipFileLocation.canWrite()) {
+ zipFileLocation = new File(System.getProperty("java.io.tmpdir"));
+ }
+ glassFishZipFile = File.createTempFile("glassfish", ".zip", zipFileLocation);
+ String filePath = glassFishZipFile.getCanonicalPath();
+ filePath = filePath.replaceAll("\\\\", "/");
+ archiveName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length());
+ } else {
archive = archive.replace('\\', '/');
archiveName = archive.substring(archive.lastIndexOf("/") + 1, archive.length());
zipFileLocation = new File(archive.substring(0, archive.lastIndexOf("/")));
glassFishZipFile = new File(archive);
if (glassFishZipFile.exists() && !create) {
- if (logger.isLoggable(Level.FINER))
- logger.finer("Found " + archive);
+ logger.log(FINER, "Found {0}", archive);
delete = false;
return glassFishZipFile;
- }
- else if (!zipFileLocation.canWrite()) {
+ } else if (!zipFileLocation.canWrite()) {
throw new IOException("Cannot write to " + archive);
}
}
- else {
- zipFileLocation = new File(".");
- if (!zipFileLocation.canWrite()) {
- zipFileLocation = new File(System.getProperty("java.io.tmpdir"));
- }
- glassFishZipFile = File.createTempFile("glassfish", ".zip", zipFileLocation);
- String filePath = glassFishZipFile.getCanonicalPath();
- filePath = filePath.replaceAll("\\\\", "/");
- archiveName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length());
- }
FileListerRelative lister = new FileListerRelative(installRoot);
lister.keepEmptyDirectories();
@@ -161,31 +157,25 @@ else if (!zipFileLocation.canWrite()) {
List resultFiles1 = Arrays.asList(files);
ArrayList resultFiles = new ArrayList(resultFiles1);
- if (logger.isLoggable(Level.FINER))
- logger.finer("Number of files to be zipped = " +
- resultFiles.size());
+ logger.finer(() -> "Number of files to be zipped = " + resultFiles.size());
Iterator iter = resultFiles.iterator();
while (iter.hasNext()) {
String fileName = iter.next();
- String fPath = fileName.substring(fileName.lastIndexOf("/") + 1);
+ String fPath = fileName.substring(fileName.lastIndexOf('/') + 1);
if (fPath.equals(glassFishZipFile.getName())) {
- if (logger.isLoggable(Level.FINER))
- logger.finer("Removing file = " + fileName);
+ logger.log(FINER, "Removing file = {0}", fileName);
iter.remove();
continue;
}
if (fileName.contains("domains") || fileName.contains("nodes")) {
iter.remove();
- }
- else if (isFileWithinBinDirectory(fileName)) {
+ } else if (isFileWithinBinDirectory(fileName)) {
binDirFiles.add(fileName);
}
}
- if (logger.isLoggable(Level.FINER))
- logger.finer("Final number of files to be zipped = " +
- resultFiles.size());
+ logger.finer(() -> "Final number of files to be zipped = " + resultFiles.size());
String[] filesToZip = new String[resultFiles.size()];
filesToZip = resultFiles.toArray(filesToZip);
@@ -218,8 +208,9 @@ public static String toString(InputStream ins) throws IOException {
char[] buffer = new char[4096];
int n;
- while ((n = reader.read(buffer)) >= 0)
+ while ((n = reader.read(buffer)) >= 0) {
sw.write(buffer, 0, n);
+ }
return sw.toString();
}
diff --git a/nucleus/common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java b/nucleus/common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java
index e95e918aa29..c89bb782bb7 100644
--- a/nucleus/common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java
+++ b/nucleus/common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -606,8 +606,7 @@ private void addDirectory(ZipOutputStream zout, File fileSource, int ignoreLengt
}
/**
- * Return a logging file details in the logging.properties file.
- *
+ * @return a logging file path from the logging.properties file.
* @throws IOException If an I/O error occurs
*/
public synchronized String getLoggingFileDetails() throws IOException {
@@ -631,7 +630,7 @@ public synchronized String getLoggingFileDetails() throws IOException {
/**
- * @return a logging file details in the logging.properties file for given target.
+ * @return a logging file path in the logging.properties file for given target.
* @throws IOException If an I/O error occurs
*/
public synchronized String getLoggingFileDetails(String targetConfigName) throws IOException {
diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/InstanceDirs.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/InstanceDirs.java
index 5dfa7aa6452..97373a306fd 100644
--- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/InstanceDirs.java
+++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/InstanceDirs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation.
+ * Copyright (c) 2024, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -65,6 +65,7 @@ public InstanceDirs(File instanceDir) throws IOException {
/**
* This constructor handles 0, 1, 2 or 3 null args.
* It is smart enough to figure out many defaults.
+ *
* @param nodeDirParentPath E.g. install-dir/nodes
* @param nodeDirName E.g. install-dir/nodes/localhost
* @param instanceName E.g. i1
@@ -74,67 +75,46 @@ public InstanceDirs(String nodeDirParentPath, String nodeDirName, String instanc
nodeDirParentPath = getNodeDirRootDefault();
}
- File nodeDirParent = new File(nodeDirParentPath);
-
+ final File nodeDirParent = new File(nodeDirParentPath);
if (!nodeDirParent.isDirectory()) {
dirs = null;
- throw new IOException(Strings.get("InstanceDirs.noNodeParent"));
+ throw new IOException(Strings.get("InstanceDirs.noNodeParent", nodeDirParent));
}
- File nodeDir;
-
+ final File nodeDir;
if (StringUtils.ok(nodeDirName)) {
nodeDir = new File(nodeDirParent, nodeDirName);
} else {
nodeDir = getTheOneAndOnlyNode(nodeDirParent);
}
-
if (!nodeDir.isDirectory()) {
dirs = null;
throw new IOException(Strings.get("InstanceDirs.badNodeDir", nodeDir));
}
- File instanceDir;
-
+ final File instanceDir;
if (StringUtils.ok(instanceName)) {
instanceDir = new File(nodeDir, instanceName);
} else {
instanceDir = getTheOneAndOnlyInstance(nodeDir);
}
-
if (!instanceDir.isDirectory()) {
dirs = null;
throw new IOException(Strings.get("InstanceDirs.badInstanceDir", instanceDir));
}
-
- // whew!!!
-
dirs = new ServerDirs(instanceDir);
}
- private File getTheOneAndOnlyNode(File parent) throws IOException {
- // look for subdirs in the parent dir -- there must be one and only one
-
- File[] files = parent.listFiles(new FileFilter() {
-
- @Override
- public boolean accept(File f) {
- return f != null && f.isDirectory();
- }
- });
- // ERROR: No node dirs
+ /** Look for subdirs in the parent dir -- there must be one and only one */
+ private File getTheOneAndOnlyNode(File parent) throws IOException {
+ File[] files = parent.listFiles(f -> f != null && f.isDirectory());
if (files == null || files.length < 1) {
- throw new IOException(
- Strings.get("InstanceDirs.noNodes", parent));
+ throw new IOException(Strings.get("InstanceDirs.noNodes", parent));
}
- // ERROR: more than one node dir child
if (files.length > 1) {
- throw new IOException(
- Strings.get("InstanceDirs.tooManyNodes", parent, files.length));
+ throw new IOException(Strings.get("InstanceDirs.tooManyNodes", parent, files.length));
}
-
- // the usual case -- one node dir child
return files[0];
}
diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/LocalStrings.properties b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/LocalStrings.properties
index 47de09275a6..e08e7dd54d2 100644
--- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/LocalStrings.properties
+++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/LocalStrings.properties
@@ -22,7 +22,7 @@ ServerDirs.invalidState=This method call is illegal because the object is in an
ServerDirs.nullArg=Null arguments are not allowed in {0}
InstanceDirs.noGrandParent=Server instances are required to have a grandparent \
directory for backward compatability. Here is the instance's directory: {0}
-InstanceDirs.noNodeParent=No node parent directory found.
+InstanceDirs.noNodeParent=No node parent directory found: {0}
InstanceDirs.tooManyNodes=There is more than one directory ({1}) in the node parent directory ({0}). Cannot choose a default node.
InstanceDirs.noNodes=There are no nodes in {0}.
InstanceDirs.badNodeDir=The specified node directory doesn''t exist: {0}
diff --git a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/RelativePathResolver.java b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/RelativePathResolver.java
index 5da7e56a354..19a4da8d7b4 100644
--- a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/RelativePathResolver.java
+++ b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/RelativePathResolver.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2024, 2025 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -21,13 +22,8 @@
import com.sun.enterprise.util.i18n.StringManagerBase;
import java.io.File;
-import java.io.IOException;
import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.glassfish.api.admin.PasswordAliasStore;
@@ -48,8 +44,6 @@
*/
public class RelativePathResolver {
- private static Logger _logger = null;
-
private static RelativePathResolver _instance = null;
private static final String ALIAS_TOKEN = "ALIAS";
@@ -99,8 +93,8 @@ public String unresolve(String path, String[] propNames) {
//assumption is that the File class can convert this to an OS
//dependent path separator (e.g. \\ on windows).
path = path.replace(File.separatorChar, '/');
- for (int i = 0; i < propNames.length; i++) {
- propVal = getPropertyValue(propNames[i], true);
+ for (String propName : propNames) {
+ propVal = getPropertyValue(propName, true);
if (propVal != null) {
//All paths returned will contain / as the separator. This will allow
//all comparison to be done using / as the separator
@@ -108,13 +102,13 @@ public String unresolve(String path, String[] propNames) {
startIdx = path.indexOf(propVal);
if (startIdx >= 0) {
path = path.substring(0, startIdx) +
- "${" + propNames[i] + "}" +
+ "${" + propName + "}" +
path.substring(startIdx + propVal.length());
}
} else {
InternalLoggerInfo.getLogger().log(Level.SEVERE,
InternalLoggerInfo.unknownProperty,
- new Object[] {propNames[i], path});
+ new Object[] {propName, path});
}
}
}
@@ -162,8 +156,9 @@ static public String getAlias(String propName)
int lastIdx = propName.length() - 1;
if (lastIdx > 1) {
propName = propName.substring(0,lastIdx);
- if (propName!=null)
- aliasName = propName.trim();
+ if (propName!=null) {
+ aliasName = propName.trim();
+ }
}
}
return aliasName;
@@ -180,8 +175,9 @@ static public String getAlias(String propName)
*/
protected String getPropertyValue(String propName, boolean bIncludingEnvironmentVariables)
{
- if(!bIncludingEnvironmentVariables)
- return null;
+ if(!bIncludingEnvironmentVariables) {
+ return null;
+ }
// Try finding the property as a system property
String result = System.getProperty(propName);
@@ -308,8 +304,8 @@ public static void main(String[] args) {
System.out.println(args[i] + " " + result + " " + resolvePath(result));
}
} else {
- for (int i = 0; i < args.length; i++) {
- System.out.println(args[i] + " " + resolvePath(args[i]));
+ for (String arg : args) {
+ System.out.println(arg + " " + resolvePath(arg));
}
}
}
@@ -333,9 +329,7 @@ public static void main(String[] args) {
* UnrecoverableKeyException if there is an error is opening or
* processing the password store
*/
- public static String getRealPasswordFromAlias(final String at) throws
- KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException,
- UnrecoverableKeyException {
+ public static String getRealPasswordFromAlias(final String at) throws KeyStoreException {
try {
if (at == null || RelativePathResolver.getAlias(at) == null) {
return ( at );