unsorted) {
/*
* (1) JVM has one known order dependency. If these 3 are here, then unlock MUST appear first in the list
@@ -226,15 +213,16 @@ private boolean hasMagic(String s) {
return s != null && s.startsWith(magic);
}
+
/**
- * Filters out unwanted properties and filters in interested properties that may need to be present by default in
- * certain environments (OS, vm.vendor)
- *
- * bnevins September 2009 There may be System Properties from V2 that cause havoc. E.g. the MBean Server sys prop from
- * V2 will be removed by upgrade code in the server but the server will blow up before it starts with a CNFE! We need to
- * remove it carefully. I.e. the user may want to set up their own MBean Server Factory so we just check to see if the
- * value is identical to the V2 class...
- *
+ * Filters out unwanted properties and filters in interested properties that may need to be
+ * present by default in certain environments (OS, vm.vendor)
+ *
+ * bnevins September 2009 There may be System Properties from V2 that cause havoc. E.g. the
+ * MBean Server sys prop from V2 will be removed by upgrade code in the server but the server
+ * will blow up before it starts with a CNFE! We need to remove it carefully. I.e. the user may
+ * want to set up their own MBean Server Factory so we just check to see if the value is
+ * identical to the V2 class...
*/
private void filter() {
// there is only one forbidden sys prop now so no need yet for fancy
@@ -341,8 +329,3 @@ private static class CompoundNameValue {
private String value;
}
}
-/**
- * Reference Section -XX:+UnlockDiagnosticVMOptions
- * -XX:+LogVMOutput
- * -XX:LogFile=${com.sun.aas.instanceRoot}/logs/jvm.log
- */
diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties b/nucleus/admin/launcher/src/main/resources/com/sun/enterprise/admin/launcher/LocalStrings.properties
similarity index 98%
rename from nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties
rename to nucleus/admin/launcher/src/main/resources/com/sun/enterprise/admin/launcher/LocalStrings.properties
index 3c517cf6ada..d8e954e8734 100644
--- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties
+++ b/nucleus/admin/launcher/src/main/resources/com/sun/enterprise/admin/launcher/LocalStrings.properties
@@ -35,7 +35,7 @@ AS_JAVA is set correctly in the config/asenv file, or java-home is set correctly
domain.xml configuration.
jvmfailure=JVM failed to start: {0}
verboseInterruption=Got an InterruptedException while waiting for the Domain to stop in verbose or watchdog mode: {0}
-nobootjar=Can''t find bootstrap jar. I looked for it here: {0}
+nobootjar=Can''t find required files: {0}
launchTime=Successfully launched in {0} msec.
serverStopped=The {0} was stopped.
UnknownJvmOptionFormat=I don''t understand the format of this jvm-option: {0}
diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java
index 9d0336cccfe..58f0b13af9f 100644
--- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java
+++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java
@@ -53,6 +53,28 @@
* one
*/
public class ASenvPropertyReader {
+
+ private static final Map ENV_TO_SYS_PROPERTY = Map.of(
+ "AS_DERBY_INSTALL", DERBY_ROOT_PROPERTY,
+ "AS_IMQ_LIB", IMQ_LIB_PROPERTY,
+ "AS_IMQ_BIN", IMQ_BIN_PROPERTY,
+ "AS_CONFIG", CONFIG_ROOT_PROPERTY,
+ "AS_INSTALL", INSTALL_ROOT_PROPERTY,
+ "AS_JAVA", JAVA_ROOT_PROPERTY_ASENV,
+ "AS_DEF_DOMAINS_PATH", DOMAINS_ROOT_PROPERTY,
+ "AS_DEF_NODES_PATH", AGENT_ROOT_PROPERTY);
+
+
+ /**
+ * Typically, only one asenv file will be read, even though there may be many
+ * ASenvPropertyReader objects. So for each unique File, only one ASenvMap
+ * is created, and all ASenvPropertyReader objects that reference the file
+ * will share the same map. The key to the propsMap is the install dir that
+ * is passed to the constructor.
+ */
+ private static final HashMap propsMap = new HashMap<>();
+ private ASenvMap props;
+
/**
* Read and process the information in asenv
* There are no arguments because the installation directory is calculated
@@ -71,21 +93,13 @@ public ASenvPropertyReader() {
* unit test classes that are not running from an official installation.
* @param installDir The Glassfish installation directory
*/
- public ASenvPropertyReader(File installDir)
- {
+ public ASenvPropertyReader(File installDir) {
synchronized (propsMap) {
- try {
- installDir = SmartFile.sanitize(installDir);
- props = propsMap.get(installDir);
- if (props == null) {
- props = new ASenvMap(installDir);
- propsMap.put(installDir, props);
- }
- }
- catch(Exception e)
- {
- // ignore -- this is universal utility code there isn't much we can
- // do.
+ installDir = SmartFile.sanitize(installDir);
+ props = propsMap.get(installDir);
+ if (props == null) {
+ props = new ASenvMap(installDir);
+ propsMap.put(installDir, props);
}
}
}
@@ -95,8 +109,7 @@ public ASenvPropertyReader(File installDir)
* trouble setting up the hostname and java root.
* @return A Map with all the properties
*/
- public Map getProps()
- {
+ public Map getProps() {
return props;
}
@@ -117,15 +130,14 @@ public String toString() {
}
- /*
+ /**
* ASenvMap is a "lazy-evaluation" map, i.e., for values that are
* expensive to calculate, the value is not calculated until it is actually
* used.
*/
- static class ASenvMap extends HashMap
- {
+ static class ASenvMap extends HashMap {
// If we find a token in a set property, this is set to true.
- boolean foundToken = false;
+ boolean foundToken;
ASenvMap(File installDir) {
put(INSTALL_ROOT_PROPERTY, installDir.getPath());
@@ -144,7 +156,9 @@ static class ASenvMap extends HashMap
@Override
public String get(Object k) {
String v = super.get(k);
- if (v != null) return v;
+ if (v != null) {
+ return v;
+ }
if (k.equals(HOST_NAME_PROPERTY)) {
v = getHostname();
put(HOST_NAME_PROPERTY, v);
@@ -171,7 +185,7 @@ public Set> entrySet() {
@Override
public boolean containsKey(Object k) {
completeMap();
- return super.containsKey((String)k);
+ return super.containsKey(k);
}
@Override
@@ -180,7 +194,7 @@ public Collection values() {
return super.values();
}
- /*
+ /**
* Add the "lazy" items to the map so that the map is complete.
*/
private void completeMap() {
@@ -188,17 +202,19 @@ private void completeMap() {
get(JAVA_ROOT_PROPERTY);
}
- /*
- * 2 things to do
- * 1) change relative paths to absolute
- * 2) change env. variables to either the actual values in the environment
- * or to another prop in asenv
+
+ /**
+ *
+ * - change relative paths to absolute
+ *
- change env. variables to either the actual values in the environment
+` * or to another prop in asenv
+ *
*/
private void postProcess(File configDir) {
if (foundToken) {
final Map env = System.getenv();
//put env props in first
- Map all = new HashMap(env);
+ Map all = new HashMap<>(env);
// now override with our props
all.putAll(this);
TokenResolver tr = new TokenResolver(all);
@@ -234,28 +250,17 @@ private void postProcess(File configDir) {
private void setProperties(File configDir) {
//Read in asenv.conf/bat and set system properties accordingly
File asenv = new File(configDir,
- GFLauncherUtils.isWindows() ?
- WINDOWS_ASENV_FILENAME : UNIX_ASENV_FILENAME);
-
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(asenv, UTF_8));
+ GFLauncherUtils.isWindows() ? WINDOWS_ASENV_FILENAME : UNIX_ASENV_FILENAME);
+ if (!asenv.exists()) {
+ return;
+ }
+ try (BufferedReader reader = new BufferedReader(new FileReader(asenv, UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
setProperty(line);
}
- }
- catch (Exception ex) {
- // Nothing to do
- }
- finally {
- try {
- if (reader != null) {
- reader.close();
- }
- }
- catch (Exception ex) {
- }
+ } catch (Exception e) {
+ throw new IllegalStateException("Could not parse " + asenv, e);
}
}
@@ -270,69 +275,70 @@ private void setProperties(File configDir) {
*
*/
private void setProperty(String line) {
- int pos = line.indexOf("=");
-
+ int pos = line.indexOf('=');
if (pos > 0) {
String lhs = (line.substring(0, pos)).trim();
String rhs = (line.substring(pos + 1)).trim();
- if (GFLauncherUtils.isWindows()) { //trim off the "set "
+ if (GFLauncherUtils.isWindows()) {
+ // trim off the "set "
lhs = (lhs.substring(3)).trim();
- }
- else { // take the quotes out
- pos = rhs.indexOf("\"");
+ } else {
+ // take the quotes out
+ pos = rhs.indexOf('"');
if (pos != -1) {
rhs = (rhs.substring(pos + 1)).trim();
- pos = rhs.indexOf("\"");
+ pos = rhs.indexOf('"');
if (pos != -1) {
rhs = (rhs.substring(0, pos)).trim();
}
}
}
- String systemPropertyName = envToPropMap.get(lhs);
+ String systemPropertyName = ENV_TO_SYS_PROPERTY.get(lhs);
if (systemPropertyName != null) {
- if (TokenResolver.hasToken(rhs)) foundToken = true;
+ if (TokenResolver.hasToken(rhs)) {
+ foundToken = true;
+ }
put(systemPropertyName, rhs);
}
}
}
- static private String getHostname() {
+ private static String getHostname() {
String hostname = "localhost";
try {
// canonical name checks to make sure host is proper
hostname = NetUtils.getCanonicalHostName();
- }
- catch (Exception ex) {
- // ignore, go with "localhost"
+ } catch (Exception ex) {
+ // ignore, go with "localhost"
}
return hostname;
}
- /*
+ /**
* Get a value for the Java installation directory. The value that is
* passed in should be the value from the ASenv config file. If it is valid
* it is returned. Otherwise, this method checks the following:
* - JAVA_HOME environment variable
* - java.home system property
*/
- static private String getJavaRoot(String fileValue) {
+ private static String getJavaRoot(String fileValue) {
// make sure we have a folder with java in it!
// note that we are not in a position to set it from domain.xml yet
// first choice -- whatever is in asenv
String javaRootName = fileValue;
- if (isValidJavaRoot(javaRootName))
+ if (isValidJavaRoot(javaRootName)) {
return javaRootName; // we are already done!
+ }
// try JAVA_HOME
javaRootName = System.getenv("JAVA_HOME");
- if (isValidJavaRoot(javaRootName))
- {
+ if (isValidJavaRoot(javaRootName)) {
javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath();
return javaRootName;
}
@@ -340,8 +346,7 @@ static private String getJavaRoot(String fileValue) {
// usually java.home is pointing at jre and ".." goes to the jdk
javaRootName = System.getProperty("java.home") + "/..";
- if (isValidJavaRoot(javaRootName))
- {
+ if (isValidJavaRoot(javaRootName)) {
javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath();
return javaRootName;
}
@@ -349,51 +354,30 @@ static private String getJavaRoot(String fileValue) {
// try java.home as-is
javaRootName = System.getProperty("java.home");
- if (isValidJavaRoot(javaRootName))
- {
+ if (isValidJavaRoot(javaRootName)) {
javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath();
return javaRootName;
}
- // TODO - should this be an Exception? A log message?
+ // TODO - should this be an Exception? A log message?
return null;
}
- static private boolean isValidJavaRoot(String javaRootName) {
- if (!GFLauncherUtils.ok(javaRootName))
+ private static boolean isValidJavaRoot(String javaRootName) {
+ if (!GFLauncherUtils.ok(javaRootName)) {
return false;
+ }
// look for ${javaRootName}/bin/java[.exe]
File f = new File(javaRootName);
- if (GFLauncherUtils.isWindows())
+ if (GFLauncherUtils.isWindows()) {
f = new File(f, "bin/java.exe");
- else
+ } else {
f = new File(f, "bin/java");
+ }
return f.exists();
}
}
-
- static private Map envToPropMap = new HashMap();
- {
- envToPropMap.put("AS_DERBY_INSTALL", DERBY_ROOT_PROPERTY);
- envToPropMap.put("AS_IMQ_LIB", IMQ_LIB_PROPERTY);
- envToPropMap.put("AS_IMQ_BIN", IMQ_BIN_PROPERTY);
- envToPropMap.put("AS_CONFIG", CONFIG_ROOT_PROPERTY);
- envToPropMap.put("AS_INSTALL", INSTALL_ROOT_PROPERTY);
- envToPropMap.put("AS_JAVA", JAVA_ROOT_PROPERTY_ASENV);
- envToPropMap.put("AS_DEF_DOMAINS_PATH", DOMAINS_ROOT_PROPERTY);
- envToPropMap.put("AS_DEF_NODES_PATH", AGENT_ROOT_PROPERTY);
- }
-
- /*
- * Typically, only one asenv file will be read, even though there may be many
- * ASenvPropertyReader objects. So for each unique File, only one ASenvMap
- * is created, and all ASenvPropertyReader objects that reference the file
- * will share the same map. The key to the propsMap is the install dir that
- * is passed to the constructor.
- */
- static private final HashMap propsMap = new HashMap();
- private ASenvMap props;
}
diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/EarlyLogger.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/EarlyLogger.java
deleted file mode 100644
index 578f8072f41..00000000000
--- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/EarlyLogger.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.util;
-
-import com.sun.enterprise.universal.i18n.LocalStringsImpl;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- * @author bnevins
- */
-public class EarlyLogger {
- private EarlyLogger() {
- // no instances allowed...
- }
-
- public static void add(Level level, String message) {
- messages.add(new LevelAndMessage(level, prepend + message));
- // also log to the console...
- logger.log(level, message);
- }
-
- public static List getEarlyMessages() {
- return messages;
- }
-
- public final static class LevelAndMessage {
-
- private final String msg;
- private final Level level;
-
- LevelAndMessage(Level l, String m) {
- msg = m;
- level = l;
- }
-
- public final String getMessage() {
- return msg;
- }
-
- public final Level getLevel() {
- return level;
- }
- }
- private final static List messages =
- new CopyOnWriteArrayList();
- private final static LocalStringsImpl strings =
- new LocalStringsImpl(EarlyLogger.class);
- private final static String prepend = strings.get("EarlyLogger.prepend");
- private final static Logger logger = Logger.getAnonymousLogger();
-}
diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/LocalStrings.properties b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/LocalStrings.properties
index 27c7795a781..4826b4ae6ea 100644
--- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/LocalStrings.properties
+++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/LocalStrings.properties
@@ -14,5 +14,4 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#
-EarlyLogger.prepend=This message was emitted before the logging service started:
column.internal=invalid number of columns ({0}), expected ({1})
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 4bc4f7959e7..5dfa7aa6452 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,4 +1,5 @@
/*
+ * Copyright (c) 2024 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
@@ -45,14 +46,16 @@
*/
public final class InstanceDirs {
+ private final ServerDirs dirs;
+
/**
* This constructor is used when the instance dir is known
*
* @param instanceDir The instance's directory
* @throws IOException If any error including not having a grandparent directory.
*/
- public InstanceDirs(File theInstanceDir) throws IOException {
- dirs = new ServerDirs(theInstanceDir);
+ public InstanceDirs(File instanceDir) throws IOException {
+ dirs = new ServerDirs(instanceDir);
if (dirs.getServerGrandParentDir() == null) {
throw new IOException(ServerDirs.strings.get("InstanceDirs.noGrandParent", dirs.getServerDir()));
@@ -62,13 +65,14 @@ public InstanceDirs(File theInstanceDir) throws IOException {
/**
* This constructor handles 0, 1, 2 or 3 null args.
* It is smart enough to figure out many defaults.
- * @param nodeDirParent E.g. install-dir/nodes
- * @param nodeDir E.g. install-dir/nodes/localhost
+ * @param nodeDirParentPath E.g. install-dir/nodes
+ * @param nodeDirName E.g. install-dir/nodes/localhost
* @param instanceName E.g. i1
*/
public InstanceDirs(String nodeDirParentPath, String nodeDirName, String instanceName) throws IOException {
- if (!StringUtils.ok(nodeDirParentPath))
+ if (!StringUtils.ok(nodeDirParentPath)) {
nodeDirParentPath = getNodeDirRootDefault();
+ }
File nodeDirParent = new File(nodeDirParentPath);
@@ -79,10 +83,11 @@ public InstanceDirs(String nodeDirParentPath, String nodeDirName, String instanc
File nodeDir;
- if (StringUtils.ok(nodeDirName))
+ if (StringUtils.ok(nodeDirName)) {
nodeDir = new File(nodeDirParent, nodeDirName);
- else
+ } else {
nodeDir = getTheOneAndOnlyNode(nodeDirParent);
+ }
if (!nodeDir.isDirectory()) {
dirs = null;
@@ -91,10 +96,11 @@ public InstanceDirs(String nodeDirParentPath, String nodeDirName, String instanc
File instanceDir;
- if (StringUtils.ok(instanceName))
+ if (StringUtils.ok(instanceName)) {
instanceDir = new File(nodeDir, instanceName);
- else
+ } else {
instanceDir = getTheOneAndOnlyInstance(nodeDir);
+ }
if (!instanceDir.isDirectory()) {
dirs = null;
@@ -111,6 +117,7 @@ private File getTheOneAndOnlyNode(File parent) throws IOException {
File[] files = parent.listFiles(new FileFilter() {
+ @Override
public boolean accept(File f) {
return f != null && f.isDirectory();
}
@@ -136,6 +143,7 @@ private File getTheOneAndOnlyInstance(File nodeDir) throws IOException {
File[] files = nodeDir.listFiles(new FileFilter() {
+ @Override
public boolean accept(File f) {
return f != null && f.isDirectory() && !"agent".equals(f.getName());
}
@@ -169,8 +177,9 @@ private String getNodeDirRootDefault() throws IOException {
String nodeDirDefault = System.getProperty(
SystemPropertyConstants.AGENT_ROOT_PROPERTY);
- if (StringUtils.ok(nodeDirDefault))
+ if (StringUtils.ok(nodeDirDefault)) {
return nodeDirDefault;
+ }
String installRootPath = getInstallRootPath();
return installRootPath + "/" + "nodes";
@@ -180,14 +189,15 @@ private String getNodeDirRootDefault() throws IOException {
* Gets the GlassFish installation root (using property com.sun.aas.installRoot),
*
* @return path of GlassFish install root
- * @throws CommandException if the GlassFish install root is not found
+ * @throws IOException if the GlassFish install root is not found
*/
protected String getInstallRootPath() throws IOException {
String installRootPath = System.getProperty(
SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
- if (!StringUtils.ok(installRootPath))
+ if (!StringUtils.ok(installRootPath)) {
throw new IOException("noInstallDirPath");
+ }
return installRootPath;
}
@@ -202,31 +212,32 @@ public InstanceDirs(ServerDirs sd) {
dirs = sd;
}
- public final String getInstanceName() {
+ public String getInstanceName() {
return dirs.getServerName();
}
- public final File getInstanceDir() {
+ public File getInstanceDir() {
return dirs.getServerDir();
}
- public final File getNodeAgentDir() {
+ public File getNodeAgentDir() {
return dirs.getServerParentDir();
}
- public final File getNodeAgentsDir() {
+ public File getNodeAgentsDir() {
return dirs.getServerGrandParentDir();
}
- public final ServerDirs getServerDirs() {
+ public ServerDirs getServerDirs() {
return dirs;
}
- public final File getDasPropertiesFile() {
+ public File getDasPropertiesFile() {
return dirs.getDasPropertiesFile();
}
- ///////////////////////////////////////////////////////////////////////////
- /////////// All Private Below /////////////////////////
- ///////////////////////////////////////////////////////////////////////////
- private final ServerDirs dirs;
+
+ @Override
+ public String toString() {
+ return super.toString() + "[" + dirs + "]";
+ }
}
diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/CommonUtilsActivator.java b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/CommonUtilsActivator.java
index 06a45a3b3d8..36a66aefe6c 100644
--- a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/CommonUtilsActivator.java
+++ b/nucleus/common/common-util/src/main/java/org/glassfish/common/util/CommonUtilsActivator.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -26,15 +27,15 @@
* @see ObjectInputOutputStreamFactoryFactory#setFactory
* @author Sanjeeb.Sahoo@Sun.COM
*/
-public class CommonUtilsActivator implements BundleActivator
-{
- public void start(BundleContext context) throws Exception
- {
- ObjectInputOutputStreamFactoryFactory.setFactory(
- new OSGiObjectInputOutputStreamFactoryImpl(context));
+public class CommonUtilsActivator implements BundleActivator {
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ ObjectInputOutputStreamFactoryFactory.setFactory(new OSGiObjectInputOutputStreamFactoryImpl(context));
}
- public void stop(BundleContext context) throws Exception
- {
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
}
}
diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocalStrings.properties b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocalStrings.properties
index 5d84a9e9772..4516618f91f 100644
--- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocalStrings.properties
+++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocalStrings.properties
@@ -1,4 +1,5 @@
#
+# Copyright (c) 2024 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
@@ -47,14 +48,13 @@ stop.domain.notDas=stop-domain only works with domains, this is a {0}
restart.server.internalError=Internal Error: {0}
restart.server.badNumModules=There should be only 1 primordial module but {0} primordial modules were found.
-restart.server.failure=Got an exception trying to restart: {0}
+restart.server.failure=Got an exception trying to restart.
restart.server.init=Server restart initiated
-restart.server.noStartupInfo=Unable to restart. Neither CLI or non-CLI startup info was found. \
-Here is what we were looking for:\n{0}\n{1}
-restart.server.asadminError=Error in Asadmin. These 3 arguments must be present on the server's \
-original command line:\n-asadmin-classpath\n-asadmin-classname\n-asadmin-args\nCould not restart.
-restart.server.nonAsadminError=Internal Error in ASMain. These 3 arguments were not set:\n\
--startup-classpath\n-startup-classname\n-startup-args\nCould not restart.
+restart.server.noStartupInfo=Unable to restart. Neither CLI or non-CLI startup info was found.\
+Here is what we were looking for: -asadmin-classpath, -asadmin-classname, -asadmin-args or -startup-classpath, -startup-classname, -startup-args,\
+but we have found just these: {0}.
+restart.server.asadminError=These properties must be set: -asadmin-classpath, -asadmin-classname, -asadmin-args
+restart.server.nonAsadminError=These properties must be set: -startup-classpath, -startup-classname, -startup-args.
restart.domain.command=Restart a running domain
diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java
index 729f540ce70..1dbedaea7d2 100644
--- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java
+++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java
@@ -26,7 +26,6 @@
import jakarta.inject.Inject;
import jakarta.inject.Provider;
-import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;
@@ -109,7 +108,7 @@ protected final void doExecute(AdminCommandContext context) {
reincarnate();
}
} catch (Exception e) {
- context.getLogger().severe(strings.get("restart.server.failure", e));
+ throw new Error(strings.get("restart.server.failure"), e);
}
final int restartType;
@@ -126,7 +125,7 @@ protected final void doExecute(AdminCommandContext context) {
///////// ALL PRIVATE BELOW ////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
- private void init(AdminCommandContext context) throws IOException {
+ private void init(AdminCommandContext context) {
logger = context.getLogger();
props = Globals.get(StartupContext.class).getArguments();
verbose = Boolean.parseBoolean(props.getProperty("-verbose", "false"));
@@ -137,8 +136,7 @@ private void reincarnate() throws Exception {
if (setupReincarnationWithAsadmin() || setupReincarnationWithOther()) {
doReincarnation();
} else {
- logger.severe(strings.get("restart.server.noStartupInfo", strings.get("restart.server.asadminError"),
- strings.get("restart.server.nonAsadminError")));
+ throw new IllegalStateException(strings.get("restart.server.noStartupInfo", props));
}
}
diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java
index 76ab49dfba6..795e9d8187f 100644
--- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java
+++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
+ * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -176,7 +176,7 @@ private void initialize() {
if (size == 0) {
continue;
}
- URL urls[] = new URL[size];
+ URL[] urls = new URL[size];
try {
for (int i=0; i < size; i++) {
urls[i] = uris[i].toURL();
@@ -226,7 +226,7 @@ protected URL findResource(String name) {
return null;
}
@Override
- protected Enumeration findResources(java.lang.String name) throws IOException {
+ protected Enumeration findResources(String name) throws IOException {
return null;
}
@Override
@@ -234,11 +234,11 @@ public URL getResource(String name) {
return null;
}
@Override
- protected Class findClass(java.lang.String name) throws ClassNotFoundException {
+ protected Class> findClass(String name) throws ClassNotFoundException {
throw new ClassNotFoundException("Class not found: " + name);
}
@Override
- protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
throw new ClassNotFoundException("Class not found: " + name);
}
}
diff --git a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/LocalStrings.properties b/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/LocalStrings.properties
deleted file mode 100644
index 5df3d6e1caa..00000000000
--- a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/LocalStrings.properties
+++ /dev/null
@@ -1,233 +0,0 @@
-#
-# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v. 2.0, which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
-# This Source Code may also be made available under the following Secondary
-# Licenses when the conditions for such availability set forth in the
-# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
-# version 2 with the GNU Classpath Exception, which is available at
-# https://www.gnu.org/software/classpath/license.html.
-#
-# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-#
-
-#
-#
-# common
-enterprise.deployment.backend.error_creating_zipitem=Error while creating zip item for: {0}
-enterprise.deployment.backend.verifier_error=Some verifier tests failed for the given application. Aborting deployment. Please verify your application using the verifier separately for more details
-enterprise.deployment.backend.optionalpkgdependencynotsatisfied=Application or stand alone module depends on some optional packages which are not present in the directory specified by System property : java.ext.dirs
-
-# AppClientModuleDeployer
-#
-enterprise.deployment.backend.DirDeployOfAppClient=App Client Directory-Deployment not supported
-# AppDD.java
-enterprise.deployment.backend.bad_file_parameter=Bad File parameter in AppDD ctor: {0}
-enterprise.deployment.backend.no_application_xml=Cannot find application.xml. Searched for: {0} -- perhaps this is not an Application?
-enterprise.deployment.backend.error_parsing_application_xml=Error parsing application.xml: {0}, {1}
-enterprise.deployment.backend.duplicate_context_root=The same context-root is used by more than one Web-Module in this Application (duplicate context-root: {0})
-enterprise.deployment.backend.homemade_parser_error=Error parsing XML with homemade parser: {0}
-#
-# AppDeployer.java
-enterprise.deployment.backend.dorequest_exception=Deployment Error
-enterprise.deployment.backend.ejbc_error=Error while running ejbc
-enterprise.deployment.backend.error_making_backup=Error making a backup copy of App in {0}
-enterprise.deployment.backend.file_source_does_not_exist=File source to be deployed does not exist: {0}
-enterprise.deployment.backend.deployment_not_dir_or_archive=Internal Error: Deployment is not a Directory or an Archive Deployment
-enterprise.deployment.backend.internal_redeploy_error=Unknown internal error trying to roll back a failed Redeployment. Error was encountered in this code: {0}
-enterprise.deployment.backend.error_deleting_tree=Could not cleanup the failed directory-redeployment files ({0}). DeploymentCleaner will eventually destroy them. -- {1}
-enterprise.deployment.backend.all_undeleted_files=The following file(s) were left(locked) from the previous deployment:\n{0}
-enterprise.deployment.backend.untouched_undeleted_files=The following file(s) were left(locked) from the previous deployment; they were not updated during this deployment and could interfere with the application:\n{0}
-
-#
-# AppDeployerBase.java
-enterprise.deployment.backend.null_applicationenvironment_object=Null ApplicationEnvironment object inside Deployment Request object
-enterprise.deployment.backend.null_appname=Null or empty appName in Deployment Request object
-enterprise.deployment.backend.attempt_to_deploy_non_ear_archive=Attempted to do an application deployment of a non-ear archive: {0}
-enterprise.deployment.backend.application_not_registered=Config says that application was not registered
-enterprise.deployment.backend.attempt_to_deploy_non_application=Internal Error: AppDeployerBase called to deploy a non-application
-enterprise.deployment.backend.undeploy_error_application_not_registered=Cannot undeploy. Application is not registered.
-enterprise.deployment.backend.undeploy_error_application_is_a_system_resource=Cannot undeploy. Application is a system resource.
-enterprise.deployment.backend.deploy_error_application_exists=Cannot deploy. Application already exists. Please select the Redeploy option.
-enterprise.deployment.backend.redeploy_error_application_does_not_exist=Cannot redeploy. Application does not exist
-enterprise.deployment.backend.redeploy_error_application_is_a_system_resource=Cannot redeploy. Application is a system resource
-enterprise.deployment.backend.error_creating_appdd=Error creating AppDD instance: {0}
-enterprise.deployment.backend.error_getting_generated_dirs=Error while attempting to get the Generated Directories: {0}
-enterprise.deployment.backend.remove_policy_error=Cannot remove policy file for {0}.
-enterprise.deployment.backend.generate_policy_error=Cannot generate policy file for {0}.
-#
-# AppReDeployer.java
-enterprise.deployment.backend.error_getting_app_location=AppsManager threw an Exception when I asked it for the location of this App: {0}
-enterprise.deployment.backend.redeployment_not_dir_or_archive=Internal Error: Redeployment is not a Directory or an Archive Redeployment
-enterprise.deployment.backend.directory_rename_error=Could not rename {0} to {1}
-#
-# AppUnDeployer.java
-enterprise.deployment.backend.error_getting_app_directory=Error attempting to get the Application Directory: {0}
-#
-# ClientJarMaker.java
-enterprise.deployment.backend.bad_app_directory=Bad application directory: {0}
-enterprise.deployment.backend.ejb_subdirectory_does_not_exist={0}: Subdirectory for EJB does not exist or is not a directory.\nSearched for this directory: {1}
-enterprise.deployment.backend.appclient_subdirectory_does_not_exist={0}: Subdirectory for App Client does not exist or is not a directory.\nSearched for this directory: {1}
-enterprise.deployment.backend.did_not_find_separator=Internal Error - did not find a {0} in the filename {1}
-#
-# ConnectorModuleDeployer.java
-enterprise.deployment.backend.redeploy_error_module_not_registered=Cannot redeploy. Module is not registered. Do a deploy.
-enterprise.deployment.backend.redeploy_error_module_registered=Cannot redeploy. Module is registered. Do a deploy.
-#
-# ContextRootChecker.java
-# ctorrErr = Internal Error: call to ContextRootChecker.ContextRootChecker with
-enterprise.deployment.backend.undeploy_error=Call to ContextRootChecker.undeploy() with a null or empty appName argument.
-enterprise.deployment.backend.null_appsmanager_object=Internal Error: call to ContextRootChecker.ContextRootChecker with null AppsManager object
-enterprise.deployment.backend.null_appName=Internal Error: call to ContextRootChecker.ContextRootChecker with null or empty appName
-enterprise.deployment.backend.error_creating_webmodulesmanager=Cannot create WebModulesManager {0}
-enterprise.deployment.backend.null_webmodulesmanager_object=Internal Error: call to ContextRootChecker.ContextRootChecker with null WebModulesManager object
-enterprise.deployment.backend.null_webname=Internal Error: call to ContextRootChecker.ContextRootChecker with null or empty webName
-enterprise.deployment.backend.error_creating_appsmanager=Cannot create AppsManager: {0}
-enterprise.deployment.backend.context_root_exists=Context-Root already exists in a deployed object: {0}
-enterprise.deployment.backend.null_appid_argument=Null or empty appID argument to update()
-enterprise.deployment.backend.error_updating_appmap=Error updating appMap: {0}
-enterprise.deployment.backend.null_instanceenvironment_object=Internal Error: call to ContextRootChecker.ContextRootChecker with null InstanceEnvironment object
-enterprise.deployment.backend.null_contextroot=Internal Error: call to ContextRootChecker.ContextRootChecker with null contextRoot
-enterprise.deployment.backend.null_contextroot_number=Internal Error: call to ContextRootChecker.ContextRootChecker with null or empty contextRoot #{0}
-enterprise.deployment.backend.config_exception_in_alreadyexistsinwebmodule=Error in ContextRootChecker.alreadyExistsInWebModule()
-#
-# Deployer.java
-enterprise.deployment.backend.null_deployment_request_object=Null Deployment Request object
-enterprise.deployment.backend.null_instanceenvironment_in_deployment_request=Null InstanceEnvironment object inside Deployment Request object
-enterprise.deployment.backend.no_manager_registered=No manager registered for {0}
-enterprise.deployment.backend.error_loading_dds=Error loading deployment descriptors for module [{0}] -- {1}
-enterprise.deployment.backend.cannot_get_validationlevel=Cannot get xml validation level from config, full is assumed. Error reported was {0}
-enterprise.deployment.backend.no_main_class=App client {0} did not specify Main-Class in its manifest as described in the Jakarta EE specification; no annotations in this app client will be processed
-enterprise.deployment.backend.appclient_mainclass_checking=Checking Main-Class settings for app clients
-enterprise.deployment.backend.appclient_mainclass_checking_failed=The following app client(s) did not specify the manifest Main-Class attribute: {0}
-enterprise.deployment.backend.archive_opt_dep_not_satisfied=Optional dependencies are not satisfied for archive [{0}], please see server.log for more details.
-#
-# DeployerFactory.java
-enterprise.deployment.backend.deployment_not_supported=Only Application Web-Module and EJB-Module Deployment is supported currently
-enterprise.deployment.backend.unknown_deployment_request_type=Internal Error: Deployment Request has an unknown command type
-#
-# DeploymentCleaner.java
-enterprise.deployment.backend.null_instanceenvironment=Null InstanceEnvironment argument
-enterprise.deployment.backend.getallapps_exception=Exception while calling AppsManager.getAllApps()
-enterprise.deployment.backend.listwebmodules_exception=Exception while calling WebModulesManager.listWebModules()
-enterprise.deployment.backend.listejbmodules_exception=Exception while calling EjbModulesManager.listEjbModules()
-enterprise.deployment.backend.listconnectormodules=Exception while calling ConnectorModulesManager.listConnectorModules()
-#
-# DeploymentRequest.java
-enterprise.deployment.backend.file_source_required=File source is required, but is not set
-enterprise.deployment.backend.name_required=Name is required, but is not set
-enterprise.deployment.backend.context_root_required=Context Root is required, but is not set
-enterprise.deployment.backend.illegal_characters_in_component_name=Illegal characters in component name. All characters must be acceptable for use in filenames. Illegal characters: {0}
-enterprise.deployment.backend.null_setname=setName called with a null name
-enterprise.deployment.backend.cannot_set_shared_flag=Illegal call to setShared(boolean). This is not an Ejb module, and only Ejb modules can have their shared attribute changed.
-enterprise.deployment.backend.no_command=Internal Error -- no command set
-enterprise.deployment.backend.invalid_isarchive_call=Internal Error -- invalid to call isArchive() for an Undeploy
-enterprise.deployment.backend.illegal_getapplicationenv_call=Illegal call to getApplicationEnv(). This is not an application.
-enterprise.deployment.backend.illegal_getmoduleenv_call=Illegal call to getModuleEnv(). This is not a module.
-enterprise.deployment.backend.null_command_type=Null command type
-enterprise.deployment.backend.unknown_deployable_object=Internal error in {0}.setEnv(): Unknown Deployable Object. It is not an Application, Web Module, Connector Module or EJB Module
-
-#DeploymentRequstRegistry.java
-another_thread_access_same_module=Another thread is accessing the same module {0}, please try later.
-
-#
-# EJBCompiler.java
-enterprise.deployment.backend.fatal_ejbc_error=Fatal Error from EJB Compiler
-enterprise.deployment.backend.ejbc_remoteexception=RemoteException attempting to create a DeploymentSessionImpl object:\n{0}
-enterprise.deployment.backend.bad_ejbc_ctx=One or more required elements are missing in ejbc context.
-
-#
-# EarExploder.java
-enterprise.deployment.backend.verify_error_module_not_present_in_ear=Verify Error: Module specified in application.xml not found in ear file: {0}
-enterprise.deployment.backend.verify_error_illegal_module_name=Verify Error: Illegal module name in Application.xml: {0}
-enterprise.deployment.backend.earexploder_verify_error=EarExploder.explode(): Internal Error. Module in application.xml cannot be located in the ear file.\nThis should not happen because verify() was supposed to detect it earlier. Filename:
-#
-# EjbFullJarMaker.java
-enterprise.deployment.backend.module_root_does_not_exist=Module Root Directory does not exist
-#
-# JarMaker.java
-enterprise.deployment.backend.error_writing_ejb_jar_with_meta_files=Error writing ejb jar file with meta files: {0}
-enterprise.deployment.backend.no_meta_inf_under_module_root=No META-INF subdirectory of Module Root Directory
-enterprise.deployment.backend.no_files_in_meta_inf=No files found in META-INF subdirectory of Module Root Directory
-enterprise.deployment.backend.directory_does_exist=No such directory: {0}
-#
-# JSPCompiler.java
-enterprise.deployment.backend.start_jspc=Beginning JSP Precompile...
-enterprise.deployment.backend.finish_jspc=Finished JSP Precompile...
-#
-# ModuleDeployer.java
-enterprise.deployment.backend.unknown_deployment_command=Unknown or missing Deployment command. It is not Deploy, Redeploy or Undeploy.
-enterprise.deployment.backend.null_moduleenvironment=Null ModuleEnvironment
-enterprise.deployment.backend.deployment_type_error=Internal Error: Deployment is not Deploy, Redeploy or Undeploy
-enterprise.deployment.backend.deployment_directory_does_not_exist=Directory to be deployed does not exist: {0}
-enterprise.deployment.backend.undeploy_error_module_not_registered=Cannot undeploy. Module is not registered.
-enterprise.deployment.backend.error_getting_module_directory=Error attempting to get the Module Directories: {0}
-enterprise.deployment.backend.modulesmanager_error_getting_module_location=ModulesManager threw an Exception when I asked it for the location of this Module: {0}
-enterprise.deployment.backend.config_exception_on_remove=Got a Config Exception trying to call EjbModulesManager.remove({0}): {1}
-enterprise.deployment.backend.module_not_registered=Config says that module was not registered
-enterprise.deployment.backend.null_moduleinfo=Internal Error: moduleInfo is null
-enterprise.deployment.backend.null_context_root=Null or empty Context Root
-enterprise.deployment.backend.error_making_module_backup=Error making a backup copy of Module in {0}
-enterprise.deployment.backend.deploy_error_module_exists=Cannot deploy. Module already exists. Set force=true for redeployment.
-enterprise.deployment.backend.undeploy_error_module_is_a_system_resource=Cannot undeploy. Module is a system resource.
-enterprise.deployment.backend.redeploy_error_module_is_a_system_resource=Cannot redeploy. Module is a system resource.
-enterprise.deployment.backend.deploy_error_dir_is_locked=Cannot deploy. {0} directory is locked and cannot be deleted: {1}
-enterprise.deployment.backend.nameAlreadyExists=Cannot deploy {0}. The name is already registered to a different type of Module or App: {1}. If you want to deploy this Module or App either (a) change the name or (b) undeploy the other Module or App first.
-enterprise.deployment.backend.jws_redeploy=The content under {0} (possibly your signed appclient jar) is now removed. Please re-sign it if needed.
-#
-# RarExploder.java
-enterprise.deployment.filename_not_rar=Filename does not end with ".rar": {0}
-#
-# WarExploder.java
-enterprise.deployment.filename_not_war=Filename does not end with ".war": {0}
-enterprise.deployment.backend.web_module_context_root_not_set=No context root set for web module
-
-enterprise.deployment.backend.cannot_create_connector_descriptor=Internal Error: Failed to create IASConnectorDescriptor for {0} {1}
-
-enterprise.deployment.backend.deploy_error_jndi_exists=Cannot deploy: JndiName {0} already exists for connector module {1}.
-#
-# DeployableObjectType.java
-enterprise.deployment.backend.cant_determine_type=Cannot determine the J2EE component type: {0}
-#
-# ClientJarArchivist.java
-enterprise.deployment.error_creating_client_jar=Unable to create client jar: {0}
-
-#
-# EjbcContextImpl.java
-enterprise.deployment.backend.invalid_deployment_mode=Unknown deployment mode: {0}
-
-#
-# J2EEModuleExploder.java
-enterprise.deployment.backend.error_saving_manifest=Could not save manifest {0} as {1}
-enterprise.deployment.backend.error_deleting_manifest=Could not delete manifest {0} in order to rename {1}
-enterprise.deployment.backend.error_restoring_manifest=Could not restore saved manifest by renaming it from {0} to {1}
-
-enterprise.deployment.backend.cannot_find_servlet=Runtime settings error. Cannot find servlet-impl-class for endpoint {0}
-
-enterprise.deployment.backend.no_files_found=There were no files found in {0}
-
-enterprise.deployment.backend.error_writing_war=Error attempting to write war: {0}
-
-enterprise.deployment.backend.saxerror_loading_dds=Error loading deployment descriptors for module [{0}] Line {1} Column {2} -- {3}
-enterprise.deployment.backend.error_getting_archivist=Error getting archivist for file {0}
-enterprise.deployment.backend.no_archivist_recognized_arch=The archive {0} is not recognized as a J2EE archive; make sure it is packaged correctly and contains the proper deployment descriptors
-enterprise.deployment.backend.error_expanding=Error expanding archive {0}; please see the server log file for more information
-enterprise.deployment.backend.could_not_expand=Could not expand entry {0} into destination {1}
-
-
-#DeploymentUtils.java
-enterprise.deployment.backend.no_generated_xmldir=Fail to load application ${0} at ${1}. Now attempt to load at ${2}. This is expected if you are upgrading from a version that is 8.1 or earlier.
-enterprise.deployment.backend.get_descriptor_failed=Failed to load deployment descriptor for application ${0}.
-
-#VersioningDeploymentUtil.java
-versioning.deployment.invalid.appname1=Excepted application name before colon: {0}
-versioning.deployment.invalid.appname2=Expected version identifier after colon: {0}.
-versioning.deployment.invalid.expression=Colon cannot be used twice in application name: {0}.
-versioning.deployment.application.noversion=Application {0} has no version registered.
-versioning.deployment.version.notreg=Version {0} not registered.
-versioning.deployment.wildcard.not.allowed=Wildcard character(s) are not allowed in a version identifier.
-versioning.deployment.dual.inplace=GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.
-versioning.deployment.osgi.warning=OSGi bundles will not use the GlassFish versioning, any version information embedded as part of the name option will be ignored
diff --git a/nucleus/deployment/common/src/main/java/org/glassfish/loader/util/ASClassLoaderUtil.java b/nucleus/deployment/common/src/main/java/org/glassfish/loader/util/ASClassLoaderUtil.java
index a4cf41c895a..b3e3f898604 100644
--- a/nucleus/deployment/common/src/main/java/org/glassfish/loader/util/ASClassLoaderUtil.java
+++ b/nucleus/deployment/common/src/main/java/org/glassfish/loader/util/ASClassLoaderUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
+ * Copyright (c) 2022, 2024 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
@@ -85,7 +85,7 @@ public class ASClassLoaderUtil {
* specified "libraries" defined for the module.
*/
public static String getModuleClassPath(ServiceLocator serviceLocator, String moduleId, String deploymentLibs) {
- deplLogger.log(FINE, () -> "ASClassLoaderUtil.getModuleClassPath " + "for module Id : " + moduleId);
+ deplLogger.log(FINE, () -> "ASClassLoaderUtil.getModuleClassPath for moduleId: " + moduleId);
StringBuilder classpath = new StringBuilder(getModulesClasspath(serviceLocator));
@@ -95,7 +95,7 @@ public static String getModuleClassPath(ServiceLocator serviceLocator, String mo
}
addDeployParamLibrariesForModule(classpath, moduleId, deploymentLibs, serviceLocator);
- deplLogger.log(FINE, () -> "Final classpath: " + classpath.toString());
+ deplLogger.log(FINE, () -> "Final classpath: " + classpath);
return classpath.toString();
}
@@ -146,7 +146,7 @@ public static URL[] getLibrariesAsURLs(Set libraries, ServerEnvironment
return null;
}
- return getDeployParamLibrariesAsURLs(env, libraries.toArray(new String[libraries.size()]), new URL[libraries.size()]);
+ return getDeployParamLibrariesAsURLs(env, libraries.toArray(String[]::new), new URL[libraries.size()]);
}
/**
@@ -254,12 +254,11 @@ public static URL[] getURLs(File[] dirs, File[] jarDirs, boolean ignoreZip) thro
* @throws IOException if an i/o error while constructing the urls
*/
public static List getURLsAsList(File[] dirs, File[] jarDirs, boolean ignoreZip) throws IOException {
- List list = new ArrayList();
+ List list = new ArrayList<>();
// Adds all directories
if (dirs != null) {
- for (int i = 0; i < dirs.length; i++) {
- File dir = dirs[i];
+ for (File dir : dirs) {
if (dir.isDirectory() || dir.canRead()) {
URL url = dir.toURI().toURL();
list.add(url);
@@ -273,15 +272,11 @@ public static List getURLsAsList(File[] dirs, File[] jarDirs, boolean ignor
// Adds all the jars
if (jarDirs != null) {
- for (int i = 0; i < jarDirs.length; i++) {
- File jarDir = jarDirs[i];
-
+ for (File jarDir : jarDirs) {
if (jarDir.isDirectory() || jarDir.canRead()) {
File[] files = jarDir.listFiles();
- for (int j = 0; j < files.length; j++) {
- File jar = files[j];
-
+ for (File jar : files) {
if (isJar(jar) || (!ignoreZip && isZip(jar))) {
list.add(jar.toURI().toURL());
@@ -297,14 +292,17 @@ public static List getURLsAsList(File[] dirs, File[] jarDirs, boolean ignor
return list;
}
+ /**
+ * Converts the list to an array
+ *
+ * @param list
+ * @return an array, never null
+ */
public static URL[] convertURLListToArray(List list) {
- // converts the list to an array
- URL[] urls = new URL[0];
- if (list != null && list.size() > 0) {
- urls = new URL[list.size()];
- urls = list.toArray(urls);
+ if (list != null && !list.isEmpty()) {
+ return list.toArray(URL[]::new);
}
- return urls;
+ return new URL[0];
}
/**
@@ -317,7 +315,7 @@ public static URL[] convertURLListToArray(List list) {
* @return urlList URL list from the given classpath
*/
public static List getURLsFromClasspath(String classpath, String delimiter, String rootPath) {
- final List urls = new ArrayList();
+ final List urls = new ArrayList<>();
if (isEmpty(classpath)) {
return urls;
@@ -420,7 +418,7 @@ public static List getAppLibDirLibrariesAsList(File appRoot, String appLibD
libDirLibraries = getURLs(null, new File[] { new File(appRoot, libPath) }, true);
}
- List allLibDirLibraries = new ArrayList();
+ List allLibDirLibraries = new ArrayList<>();
for (URL url : libDirLibraries) {
allLibDirLibraries.add(url);
}
@@ -437,12 +435,12 @@ public static List getAppLibDirLibrariesAsList(File appRoot, String appLibD
}
public static List getLibDirectoryJarURIs(File moduleLibDirectory) throws Exception {
- List libLibraryURIs = new ArrayList();
+ List libLibraryURIs = new ArrayList<>();
File[] jarFiles = moduleLibDirectory.listFiles(pathname -> pathname.getAbsolutePath().endsWith(".jar"));
if (jarFiles != null && jarFiles.length > 0) {
for (File jarFile : jarFiles) {
- libLibraryURIs.add(Util.toURI(jarFile.toURL()));
+ libLibraryURIs.add(Util.toURI(jarFile.toURI().toURL()));
}
}
diff --git a/nucleus/deployment/common/src/main/resources/org/glassfish/deployment/common/LocalStrings.properties b/nucleus/deployment/common/src/main/resources/org/glassfish/deployment/common/LocalStrings.properties
index 11fe5ae2917..efa671e0cfb 100644
--- a/nucleus/deployment/common/src/main/resources/org/glassfish/deployment/common/LocalStrings.properties
+++ b/nucleus/deployment/common/src/main/resources/org/glassfish/deployment/common/LocalStrings.properties
@@ -155,10 +155,6 @@ enterprise.deployment.backend.no_meta_inf_under_module_root=No META-INF subdirec
enterprise.deployment.backend.no_files_in_meta_inf=No files found in META-INF subdirectory of Module Root Directory
enterprise.deployment.backend.directory_does_exist=No such directory: {0}
#
-# JSPCompiler.java
-enterprise.deployment.backend.start_jspc=Beginning JSP Precompile...
-enterprise.deployment.backend.finish_jspc=Finished JSP Precompile...
-#
# ModuleDeployer.java
enterprise.deployment.backend.unknown_deployment_command=Unknown or missing Deployment command. It is not Deploy, Redeploy or Undeploy.
enterprise.deployment.backend.null_moduleenvironment=Null ModuleEnvironment
diff --git a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
index f957f51e3d8..c2ee37046d8 100644
--- a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
+++ b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
@@ -103,6 +103,7 @@ public void setUp() throws IOException {
@AfterEach
public void tearDown() {
+ assertThat(deplLogger.getHandlers(), arrayContainingInAnyOrder(handler));
if (archiveDir != null) {
clean(archiveDir);
}
@@ -150,12 +151,15 @@ private File tempDir() throws IOException {
}
private void clean(final File dir) {
- for (File f : dir.listFiles()) {
- if (f.isDirectory()) {
- clean(f);
- }
- if (!f.delete()) {
- f.deleteOnExit();
+ File[] files = dir.listFiles();
+ if (files != null) {
+ for (File f : files) {
+ if (f.isDirectory()) {
+ clean(f);
+ }
+ if (!f.delete()) {
+ f.deleteOnExit();
+ }
}
}
if (!dir.delete()) {
@@ -384,29 +388,29 @@ public void testOpenWithPreexistingDir() throws Exception {
}
private void createPreexistingDir() throws IOException {
- for (String entryName : usualEntryNames) {
- final File f = fileForPath(archiveDir, entryName);
- final File parentDir = f.getParentFile();
- if(parentDir != null) {
- parentDir.mkdirs();
- }
- try {
- f.createNewFile();
- } catch (Exception ex) {
- throw new IOException(f.getAbsolutePath(), ex);
- }
- }
- }
+ for (String entryName : usualEntryNames) {
+ final File f = fileForPath(archiveDir, entryName);
+ final File parentDir = f.getParentFile();
+ if (parentDir != null) {
+ parentDir.mkdirs();
+ }
+ try {
+ f.createNewFile();
+ } catch (Exception ex) {
+ throw new IOException(f.getAbsolutePath(), ex);
+ }
+ }
+ }
private File fileForPath(File anchor, final String path) {
- final String[] interveningDirNames = path.split("/");
- File interveningDir = anchor;
- for (int i = 0; i < interveningDirNames.length - 1; i++) {
- String name = interveningDirNames[i];
- interveningDir = new File(interveningDir, name + "/");
- }
- return new File(interveningDir,interveningDirNames[interveningDirNames.length - 1]);
- }
+ final String[] interveningDirNames = path.split("/");
+ File interveningDir = anchor;
+ for (int i = 0; i < interveningDirNames.length - 1; i++) {
+ String name = interveningDirNames[i];
+ interveningDir = new File(interveningDir, name + "/");
+ }
+ return new File(interveningDir, interveningDirNames[interveningDirNames.length - 1]);
+ }
@Test
@DisabledOnOs(OS.WINDOWS)
@@ -422,6 +426,7 @@ public void testInaccessibleDirectoryInFileArchive() throws Exception {
// Try to list the files. This should fail with our logger getting one record.
final Vector fileList = new Vector<>();
handler.reset();
+ assertThat(deplLogger.getHandlers(), arrayContainingInAnyOrder(handler));
archive.getListOfFiles(lower, fileList, null /* embeddedArchives */, deplLogger);
List logRecords = handler.getAll();