diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java index 8856301bb52..1138835bf87 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.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 @@ -74,9 +74,9 @@ public String getVersionIdentifier(ReadableArchive archive) { GFCarXMLParser gfXMLParser = new GFCarXMLParser(); versionIdentifier = gfXMLParser.extractVersionIdentifierValue(archive); } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.SEVERE, e.getMessage(), e); } catch (XMLStreamException e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.SEVERE, e.getMessage(), e); } return versionIdentifier; diff --git a/appserver/deployment/jakartaee-core/src/main/java/org/glassfish/javaee/core/deployment/JavaEEDeployer.java b/appserver/deployment/jakartaee-core/src/main/java/org/glassfish/javaee/core/deployment/JavaEEDeployer.java index 94d46adcf65..d4530eaa75c 100644 --- a/appserver/deployment/jakartaee-core/src/main/java/org/glassfish/javaee/core/deployment/JavaEEDeployer.java +++ b/appserver/deployment/jakartaee-core/src/main/java/org/glassfish/javaee/core/deployment/JavaEEDeployer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -137,13 +137,13 @@ protected String getModuleClassPath(DeploymentContext ctx) { * @return The instance classpath */ protected String getCommonClassPath() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); File libDir = env.getLibPath(); String libDirPath = libDir.getAbsolutePath(); // Append domain_root/lib/classes - sb.append(libDirPath + File.separator + "classes"); + sb.append(libDirPath).append(File.separator).append("classes"); sb.append(File.pathSeparator); // Append domain_root/lib/[*.jar|*.zip] @@ -151,7 +151,7 @@ protected String getCommonClassPath() { if (files != null) { for (String file : files) { if (file.endsWith(".jar") || file.endsWith(".zip")) { - sb.append(libDirPath + File.separator + file); + sb.append(libDirPath).append(File.separator).append(file); sb.append(File.pathSeparator); } } diff --git a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java index 79790d7bdb4..1365a43ae98 100644 --- a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java +++ b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.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 @@ -91,9 +91,9 @@ public String getVersionIdentifier(ReadableArchive archive) { GFEjbJarXMLParser gfXMLParser = new GFEjbJarXMLParser(archive); versionIdentifier = gfXMLParser.extractVersionIdentifierValue(archive); } catch (XMLStreamException e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.SEVERE, e.getMessage(), e); } return versionIdentifier; } @@ -145,17 +145,13 @@ public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext co } try { - final DeploymentContext dc = context; - final ClassLoader cl = cloader; - - AccessController.doPrivileged( - new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.ejb, dc, cl)); + AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction( + SMGlobalPolicyUtil.CommponentType.ejb, context, cloader)); } catch (PrivilegedActionException e) { throw new SecurityException(e.getException()); } } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); throw new RuntimeException(e); } return cloader; diff --git a/appserver/extras/embedded/common/bootstrap/pom.xml b/appserver/extras/embedded/common/bootstrap/pom.xml index 80f9740b943..bc1b2064cfa 100644 --- a/appserver/extras/embedded/common/bootstrap/pom.xml +++ b/appserver/extras/embedded/common/bootstrap/pom.xml @@ -81,8 +81,7 @@ jar false ${project.build.directory}/classes - **/OSGiFrameworkLauncher**,**/AutoProcessor** - META-INF/** + **/OSGiFrameworkLauncher** diff --git a/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java b/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java index 4e20431c094..fbfe11066f2 100644 --- a/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java +++ b/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java @@ -51,6 +51,7 @@ import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.PLATFORM_PROPERTY_KEY; import static com.sun.enterprise.util.io.FileUtils.USER_HOME; import static org.glassfish.embeddable.GlassFishProperties.CONFIG_FILE_URI_PROP_NAME; +import static org.osgi.framework.Constants.BUNDLE_VERSION; import static org.osgi.framework.Constants.FRAMEWORK_STORAGE; import static org.osgi.framework.Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA; @@ -109,8 +110,8 @@ public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishExc URI jar = null; try { jar = uberJarURI != null ? new URI(uberJarURI) : Util.whichJar(GlassFishRuntime.class); - } catch (URISyntaxException ex) { - logger.log(Level.SEVERE, null, ex); + } catch (URISyntaxException e) { + throw new IllegalStateException(e); } // XXX : Commented out by Prasad , we are again looking for instance root here. Why ? @@ -151,7 +152,7 @@ public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishExc String autoStartBundleLocation = "jar:" + jar.toString() + "!/modules/installroot-builder_jar/," + "jar:" + jar.toString() + "!/modules/instanceroot-builder_jar/," + - "jar:" + jar.toString() + "!/modules/kernel_jar/"; // TODO :: was modules/glassfish_jar + "jar:" + jar.toString() + "!/modules/kernel_jar/"; if (isOSGiEnv()) { autoStartBundleLocation = autoStartBundleLocation + @@ -182,8 +183,8 @@ public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishExc autostartBundle.start(Bundle.START_TRANSIENT); logger.log(Level.FINER, "Started autostartBundle {0}", autostartBundle); return getService(GlassFishRuntime.class, context); - } catch (Throwable t) { - throw new GlassFishException(new Exception(t)); + } catch (Exception e) { + throw new GlassFishException(e); } } @@ -201,10 +202,10 @@ private boolean isOSGiEnv() { } public T getService(Class type, BundleContext context) throws Exception { - ServiceTracker tracker = new ServiceTracker(context, type.getName(), null); + ServiceTracker tracker = new ServiceTracker<>(context, type.getName(), null); try { tracker.open(true); - return type.cast(tracker.waitForService(0)); + return tracker.waitForService(0); } finally { // no need to track further tracker.close(); @@ -233,7 +234,7 @@ private String loadVersion() { URL manifestURL = UberJarOSGiGlassFishRuntimeBuilder.class.getResource("/META-INF/MANIFEST.MF"); try (InputStream manifestStream = manifestURL.openStream()) { Manifest manifest = new Manifest(manifestStream); - return manifest.getMainAttributes().getValue(org.osgi.framework.Constants.BUNDLE_VERSION); + return manifest.getMainAttributes().getValue(BUNDLE_VERSION); } catch (IOException e) { throw new IllegalStateException("Could not load version from the manifest file.", e); } diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java index 70d71ae10cf..844f2d48af4 100644 --- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java +++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation. + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -46,7 +46,6 @@ import java.io.PrintWriter; import java.io.Serializable; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -323,7 +322,7 @@ void isValid(ManagedConnectionImpl managedConnectionImpl) throws ResourceExcepti boolean connectionValidationRequired = (conVal == null) ? false : - Boolean.valueOf(conVal.toLowerCase(Locale.getDefault())); + Boolean.parseBoolean(conVal.toLowerCase(Locale.getDefault())); if (!connectionValidationRequired) { return; } @@ -529,7 +528,7 @@ void resetIsolation(ManagedConnectionImpl managedConnectionImpl, int tranIsol) t if (transactionIsolation != null && !transactionIsolation.isEmpty()) { String guaranteeIsolationLevel = spec.getDetail(GUARANTEEISOLATIONLEVEL); if (guaranteeIsolationLevel != null && !guaranteeIsolationLevel.isEmpty()) { - boolean guarantee = Boolean.valueOf(guaranteeIsolationLevel); + boolean guarantee = Boolean.parseBoolean(guaranteeIsolationLevel); if (guarantee) { int tranIsolationInt = getTransactionIsolationInt(transactionIsolation); try { @@ -572,8 +571,8 @@ private void detectSqlTraceListeners() { // Load the listener class try { listenerClass = Thread.currentThread().getContextClassLoader().loadClass(sqlTraceListener); - } catch (ClassNotFoundException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_cnfe", sqlTraceListener); + } catch (ClassNotFoundException e) { + _logger.log(SEVERE, "Failed to load class: " + sqlTraceListener, e); } Class intf[] = listenerClass.getInterfaces(); for (Class interfaceName : intf) { @@ -590,16 +589,8 @@ private void detectSqlTraceListeners() { listener = (SQLTraceListener) constructor.newInstance(initargs); } } - } catch (InstantiationException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex.getMessage()); - } catch (IllegalAccessException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex.getMessage()); - } catch (IllegalArgumentException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex.getMessage()); - } catch (InvocationTargetException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex.getMessage()); - } catch (SecurityException ex) { - _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex.getMessage()); + } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException ex) { + _logger.log(SEVERE, "jdbc.sql_trace_listener_exception", ex); } sqlTraceDelegator.registerSQLTraceListener(listener); } @@ -1338,7 +1329,7 @@ protected void computeStatementWrappingStatus() { boolean poolProperty = false; String statementWrappingString = getStatementWrapping(); if (statementWrappingString != null) { - poolProperty = Boolean.valueOf(statementWrappingString); + poolProperty = Boolean.parseBoolean(statementWrappingString); } if (wrapStatement == JVM_OPTION_STATEMENT_WRAPPING_ON @@ -1436,7 +1427,7 @@ private void detectStatementLeakSupport() { String stmtLeakReclaim = getStatementLeakReclaim(); if (stmtLeakTimeout != null) { statementLeakTimeout = Integer.parseInt(stmtLeakTimeout) * 1000L; - statementLeakReclaim = Boolean.valueOf(stmtLeakReclaim); + statementLeakReclaim = Boolean.parseBoolean(stmtLeakReclaim); if (_logger.isLoggable(FINE)) { _logger.log(FINE, "StatementLeakTimeout in seconds: " + statementLeakTimeout + " & StatementLeakReclaim: " + statementLeakReclaim + " for pool : " + getPoolInfo()); diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/resources/com/sun/gjc/spi/LogStrings.properties b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/resources/com/sun/gjc/spi/LogStrings.properties index 68f110585c1..129ef0a2dde 100644 --- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/resources/com/sun/gjc/spi/LogStrings.properties +++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/resources/com/sun/gjc/spi/LogStrings.properties @@ -1,4 +1,5 @@ # +# Copyright (c) 2024 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 @@ -178,9 +179,7 @@ jdbc.jdbc_factory_class_load_exception=RAR9002 : Exception while getting Proxied RAR9002.diag.cause.1=Connection object could be null RAR9002.diag.cause.2=Initialization provoked by method could have failed. RAR9002.diag.cause.3=Underlying method inaccessible. -jdbc.sql_trace_listener_cnfe=RAR9003 : Sql tracing : ClassNotFoundException while trying to load class : {0} -RAR9003.diag.cause.1=Sql trace listener class name is not in the classpath. -jdbc.sql_trace_listener_exception=RAR9004 : Exception while introspecting SQL trace listeners : {0} +jdbc.sql_trace_listener_exception=RAR9004 : Exception while introspecting SQL trace listeners RAR9004.diag.cause.1=Constructor of the sql trace listener provided does not have enough access. RAR9004.diag.cause.2=Sql trace listener does not implement org.glassfish.api.jdbc.SQLTraceListener. RAR9004.diag.cause.3=Error while instantiating sql trace listener class provided. diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/ClusterITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/ClusterITest.java index 28ce29e0b7a..2b52632f027 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/ClusterITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/ClusterITest.java @@ -16,7 +16,6 @@ */ package org.glassfish.main.admin.test; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -79,15 +78,11 @@ public void createClusterTest() { @Test @Order(2) public void deployAppToClusterTest() { - String warFile = getWar().getAbsolutePath(); + String warFile = TestResources.createSimpleWarDeployment(TEST_APP_NAME).getAbsolutePath(); assertThat(ASADMIN.exec("deploy", "--target", CLUSTER_NAME, "--name", TEST_APP_NAME, "--contextroot", TEST_APP_NAME, warFile), asadminOK()); } - private static File getWar() { - return TestResources.createSimpleWarDeployment(TEST_APP_NAME); - } - @Test @Order(3) public void createInstancesTest() { diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/OSGiCommandsITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/OSGiCommandsITest.java index 407938ed90a..10c2a22e9d4 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/OSGiCommandsITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/OSGiCommandsITest.java @@ -56,7 +56,6 @@ public static void waitOsgiReady() throws Exception { if (!result.isError()) { return; } - Thread.sleep(1000); } } @@ -127,7 +126,7 @@ public void osgiShell() throws IOException { private String newCmdSession() throws Exception { List value = runCmd("osgi", "--session", "new"); if (value.size() != 1) { - throw new Exception("Unexpected output: \n " + value); + throw new AssertionError("Unexpected output: \n " + value); } return value.get(0); } diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/webapp/HttpServerNameITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/webapp/HttpServerNameITest.java index 6000e5d90b5..fbb5d159afd 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/webapp/HttpServerNameITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/webapp/HttpServerNameITest.java @@ -13,9 +13,9 @@ * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ + package org.glassfish.main.admin.test.webapp; -import java.io.IOException; import java.net.HttpURLConnection; import java.util.concurrent.atomic.AtomicBoolean; @@ -24,7 +24,6 @@ import org.glassfish.main.itest.tools.asadmin.Asadmin; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; @@ -33,6 +32,7 @@ import static org.glassfish.main.itest.tools.asadmin.AsadminResultMatcher.asadminOK; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.stringContainsInOrder; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class HttpServerNameITest { @@ -43,7 +43,6 @@ public class HttpServerNameITest { private static final AtomicBoolean APP_DEPLOYED = new AtomicBoolean(); - @ParameterizedTest(name = "[{index}] testServerName: {0}") @CsvSource({ "'Plain host name', hostname1, http://hostname1:8080/", "'Plain domain name', my.domain.com, http://my.domain.com:8080/", @@ -53,7 +52,8 @@ public class HttpServerNameITest { "'Secure domain name and port', https://my.domain.com:123, https://my.domain.com:123/", "'Secure domain name and standard port', https://my.domain.com:443, https://my.domain.com/" }) - public void testHostName(String description, String serverName, String expectedUrlPrefix) throws IOException, InterruptedException { + @ParameterizedTest(name = "[{index}] testServerName: {0}") + public void testHostName(String description, String serverName, String expectedUrlPrefix) throws Exception { assertThat(ASADMIN.exec("set", SERVER_NAME_PROPERTY + "=" + serverName), asadminOK()); final HttpURLConnection conn = GlassFishTestEnvironment.openConnection(HTTP_PORT, "/" + TEST_APP_NAME); @@ -73,7 +73,7 @@ static void deploy() { @AfterAll static void undeploy() { - Assumptions.assumeTrue(APP_DEPLOYED.get()); + assumeTrue(APP_DEPLOYED.get()); assertThat(ASADMIN.exec("undeploy", TEST_APP_NAME), asadminOK()); } @@ -81,5 +81,4 @@ static void undeploy() { void cleanup() { ASADMIN.exec("set", SERVER_NAME_PROPERTY + "="); } - } diff --git a/appserver/tests/application/src/test/java/org/glassfish/main/test/app/connpool/SQLTraceListenerTest.java b/appserver/tests/application/src/test/java/org/glassfish/main/test/app/connpool/SQLTraceListenerTest.java index 3f6296eb200..2107cd797d9 100644 --- a/appserver/tests/application/src/test/java/org/glassfish/main/test/app/connpool/SQLTraceListenerTest.java +++ b/appserver/tests/application/src/test/java/org/glassfish/main/test/app/connpool/SQLTraceListenerTest.java @@ -48,14 +48,10 @@ public class SQLTraceListenerTest { private static final System.Logger LOG = System.getLogger(SQLTraceListenerTest.class.getName()); - private static final String RESOURCE_ROOT = "src/main/resources/" + SqlListenerApplication.class.getPackageName().replace(".", "/"); - private static final String LIB_FILE_NAME = "lib.jar"; - private static final String WEBAPP_FILE_NAME = "webapp.war"; private static final String WEBAPP_NAME = "webapp"; - private static final String POOL_NAME = "DerbyPool"; private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin(); @@ -136,13 +132,13 @@ private static File createSqlTraceListenerLib() throws IOException { return appLib; } - private static File createWebApp() throws IOException { + private static File createWebApp() { WebArchive webArchive = ShrinkWrap.create(WebArchive.class) .addClass(SqlListenerApplication.class) .addClass(SqlListenerEndpoint.class) .addClass(Employee.class) - .addAsResource(new File(RESOURCE_ROOT, "/META-INF/persistence.xml"), "/META-INF/persistence.xml") - .addAsResource(new File(RESOURCE_ROOT, "/META-INF/load.sql"), "/META-INF/load.sql"); + .addAsResource(SqlListenerApplication.class.getPackage(), "/META-INF/persistence.xml", "/META-INF/persistence.xml") + .addAsResource(SqlListenerApplication.class.getPackage(), "/META-INF/load.sql", "/META-INF/load.sql"); LOG.log(INFO, webArchive.toString(true)); diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/mbeans/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/catalina/mbeans/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/coyote/http11/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/coyote/http11/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/buf/res/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/buf/res/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/collections/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/collections/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/compat/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/compat/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/http/res/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/http/res/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/net/res/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/net/res/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/res/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/res/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/apache/tomcat/util/threads/res/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/apache/tomcat/util/threads/res/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-core/src/main/java/org/glassfish/web/util/.gitkeep_empty_dir b/appserver/web/web-core/src/main/java/org/glassfish/web/util/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebDeployer.java b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebDeployer.java index 3e78639fcc8..f1184100ce0 100644 --- a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebDeployer.java +++ b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebDeployer.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -28,6 +29,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.api.admin.ServerEnvironment; import org.glassfish.api.container.RequestDispatcher; import org.glassfish.api.deployment.DeployCommandParameters; import org.glassfish.api.deployment.DeploymentContext; @@ -82,6 +84,7 @@ public MetaData getMetaData() { new Class[] {WebBundleDescriptorImpl.class}, new Class[] {Application.class}); } + @Override public V loadMetaData(Class type, DeploymentContext dc) { WebBundleDescriptorImpl wbd = dc.getModuleMetaData(WebBundleDescriptorImpl.class); @@ -98,14 +101,16 @@ public V loadMetaData(Class type, DeploymentContext dc) { String contextRoot = params.contextroot; if(contextRoot==null) { contextRoot = wbd.getContextRoot(); - if("".equals(contextRoot)) + if("".equals(contextRoot)) { contextRoot = null; + } } if(contextRoot==null) { contextRoot = params.previousContextRoot; } - if(contextRoot==null) + if(contextRoot==null) { contextRoot = ((GenericHandler)dc.getArchiveHandler()).getDefaultApplicationNameFromArchiveName(dc.getOriginalSource()); + } if (!contextRoot.startsWith("/")) { contextRoot = "/" + contextRoot; @@ -168,6 +173,7 @@ public WebApplication load(WebContainer container, DeploymentContext dc) { } + @Override public void unload(WebApplication webApplication, DeploymentContext dc) { } @@ -183,17 +189,14 @@ void runJSPC(final DeploymentContext dc) throws DeploymentException { final WebBundleDescriptorImpl wbd = dc.getModuleMetaData( WebBundleDescriptorImpl.class); try { - final File outDir = dc.getScratchDir(env.kCompileJspDirName); + final File outDir = dc.getScratchDir(ServerEnvironment.kCompileJspDirName); final File inDir = dc.getSourceDir(); - StringBuilder classpath = new StringBuilder( - super.getCommonClassPath()); + StringBuilder classpath = new StringBuilder(super.getCommonClassPath()); classpath.append(File.pathSeparatorChar); - classpath.append(ASClassLoaderUtil.getModuleClassPath( - sc.getDefaultServices(), - wbd.getApplication().getName(), - dc.getCommandParameters( - DeployCommandParameters.class).libraries)); + final DeployCommandParameters dcParams = dc.getCommandParameters(DeployCommandParameters.class); + classpath.append(ASClassLoaderUtil.getModuleClassPath(sc.getDefaultServices(), + wbd.getApplication().getName(), dcParams.libraries)); classpath.append(File.pathSeparatorChar); classpath.append(super.getModuleClassPath(dc)); JSPCompiler.compile(inDir, outDir, wbd, classpath.toString(), sc); diff --git a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModuleListener.java b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModuleListener.java index ac32dc2a5b2..df83e1dacdb 100644 --- a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModuleListener.java +++ b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModuleListener.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 @@ -28,6 +28,7 @@ import jakarta.servlet.ServletContext; +import java.io.File; import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -82,15 +83,17 @@ final class WebModuleListener implements LifecycleListener { */ private final WebBundleDescriptor webBundleDescriptor; private final WebContainer webContainer; + private boolean includeInitialized; + private List includeJars; + /** * Constructor. * * @param webContainer - * @param explodedLocation The location where this web module is exploded * @param wbd descriptor for this module. */ - public WebModuleListener(WebContainer webContainer, WebBundleDescriptor wbd) { + WebModuleListener(WebContainer webContainer, WebBundleDescriptor wbd) { this.webContainer = webContainer; this.webBundleDescriptor = wbd; } @@ -207,8 +210,8 @@ private void configureJsp(WebModule webModule) { if (bean != null && bean.getJspConfig() != null) { WebProperty[] props = bean.getJspConfig().getWebProperty(); for (WebProperty prop : props) { - String pname = prop.getAttributeValue("name"); - String pvalue = prop.getAttributeValue("value"); + String pname = prop.getValue("name"); + String pvalue = prop.getValue("value"); if (_logger.isLoggable(FINE)) { _logger.log(FINE, LogFacade.JSP_CONFIG_PROPERTY, "[" + webModule.getID() + "] is [" + pname + "] = [" + pvalue + "]"); } @@ -239,7 +242,7 @@ private void configureJsp(WebModule webModule) { _logger.log(FINE, LogFacade.SYS_CLASSPATH, webModule.getID() + " is " + sysClassPath); } - if (sysClassPath.equals("")) { + if (sysClassPath.isEmpty()) { // In embedded mode, services returns SingleModulesRegistry and // it has no modules. // Try "java.class.path" system property instead. @@ -282,9 +285,6 @@ private static void initializeServicesFromClassLoader(ServiceLocator serviceLoca } } - private boolean includeInitialized; - private List includeJars; - private void initIncludeJars() { if (includeInitialized) { return; @@ -321,12 +321,12 @@ private boolean included(String path) { return false; } - /* + /** * Remove unnecessary system jars, to improve performance */ private String trimSysClassPath(String sysClassPath) { - if (sysClassPath == null || sysClassPath.equals("")) { + if (sysClassPath == null || sysClassPath.isEmpty()) { return ""; } initIncludeJars(); @@ -334,16 +334,15 @@ private String trimSysClassPath(String sysClassPath) { // revert to previous behavior, i.e. no trimming return sysClassPath; } - String sep = System.getProperty("path.separator"); StringBuilder ret = new StringBuilder(); - StringTokenizer tokenizer = new StringTokenizer(sysClassPath, sep); + StringTokenizer tokenizer = new StringTokenizer(sysClassPath, File.pathSeparator); String mySep = ""; while (tokenizer.hasMoreElements()) { String path = tokenizer.nextToken(); if (included(path)) { ret.append(mySep); ret.append(path); - mySep = sep; + mySep = File.pathSeparator; } } return ret.toString(); diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/jsp/JSPCompiler.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/jsp/JSPCompiler.java index 3b7d44aea21..142d8f56f34 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/jsp/JSPCompiler.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/jsp/JSPCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to Eclipse Foundation. + * Copyright (c) 2021, 2024 Contributors to 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 @@ -40,7 +40,6 @@ import java.io.File; import java.util.Enumeration; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -55,40 +54,37 @@ import org.glassfish.web.deployment.runtime.SunWebAppImpl; import org.glassfish.web.deployment.runtime.WebProperty; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.INFO; + public final class JSPCompiler { + private static final Logger LOG = LogFacade.getLogger(); + + public static void compile(File inWebDir, File outWebDir, WebBundleDescriptor wbd, ServerContext serverContext) throws DeploymentException { - //to resolve ambiguity - final String amb = null; - compile(inWebDir, outWebDir, wbd, amb, serverContext); + compile(inWebDir, outWebDir, wbd, (String) null, serverContext); } - public static void compile(File inWebDir, File outWebDir, - WebBundleDescriptor wbd, List classpathList, - ServerContext serverContext) - throws DeploymentException { - String classpath = null; - if (classpathList != null) { - classpath = getClasspath(classpathList); - } + + public static void compile(File inWebDir, File outWebDir, WebBundleDescriptor wbd, List classpathList, + ServerContext serverContext) throws DeploymentException { + String classpath = classpathList == null ? null : getClasspath(classpathList); compile(inWebDir, outWebDir, wbd, classpath, serverContext); } - //////////////////////////////////////////////////////////////////////////// - - public static void compile(File inWebDir, File outWebDir, - WebBundleDescriptor wbd, String classpath, - ServerContext serverContext) - throws DeploymentException { + public static void compile(File inWebDir, File outWebDir, WebBundleDescriptor wbd, String classpath, + ServerContext serverContext) throws DeploymentException { + LOG.log(Level.FINEST, "Compiling JSP: in={0}, out={1}, classpath={2}", + new Object[] {inWebDir, outWebDir, classpath}); JspC jspc = new JspC(); - if (classpath != null && classpath.length() >0) { + if (classpath != null && !classpath.isEmpty()) { jspc.setClassPath(classpath); } - // START SJSAS 6311155 String appName = wbd.getApplication().getName(); // so far, this is not segragated per web bundle, all web-bundles will get the @@ -96,7 +92,6 @@ public static void compile(File inWebDir, File outWebDir, String sysClassPath = ASClassLoaderUtil.getModuleClassPath( serverContext.getDefaultServices(), appName, null); jspc.setSystemClassPath(sysClassPath); - // END SJSAS 6311155 verify(inWebDir, outWebDir); @@ -104,7 +99,7 @@ public static void compile(File inWebDir, File outWebDir, jspc.setOutputDir(outWebDir.getAbsolutePath()); jspc.setUriroot(inWebDir.getAbsolutePath()); jspc.setCompile(true); - logger.log(Level.INFO, LogFacade.START_MESSAGE); + LOG.log(INFO, LogFacade.START_MESSAGE); try { jspc.execute(); @@ -121,16 +116,14 @@ public static void compile(File inWebDir, File outWebDir, if(files == null || files.length <= 0) { if (!outWebDir.delete()) { - logger.log(Level.FINE, LogFacade.CANNOT_DELETE_FILE, outWebDir); + LOG.log(FINE, LogFacade.CANNOT_DELETE_FILE, outWebDir); } } - logger.log(Level.INFO, LogFacade.FINISH_MESSAGE); + LOG.log(INFO, LogFacade.FINISH_MESSAGE); } } - //////////////////////////////////////////////////////////////////////////// - private static void verify(File inWebDir, File outWebDir) throws DeploymentException { // inWebDir must exist, outWebDir must either exist or be creatable if (!FileUtils.safeIsDirectory(inWebDir)) { @@ -139,7 +132,7 @@ private static void verify(File inWebDir, File outWebDir) throws DeploymentExcep if (!FileUtils.safeIsDirectory(outWebDir)) { if (!outWebDir.mkdirs()) { - logger.log(Level.FINE, LogFacade.CANNOT_DELETE_FILE, outWebDir); + LOG.log(FINE, LogFacade.CANNOT_DELETE_FILE, outWebDir); } if (!FileUtils.safeIsDirectory(outWebDir)) { @@ -148,9 +141,7 @@ private static void verify(File inWebDir, File outWebDir) throws DeploymentExcep } } - //////////////////////////////////////////////////////////////////////////// - - private static String getClasspath(List paths) { + private static String getClasspath(List paths) { if (paths == null) { return null; } @@ -160,14 +151,12 @@ private static String getClasspath(List paths) { StringBuilder sb = new StringBuilder(); boolean first = true; - for (Iterator it = paths.iterator(); it.hasNext(); ) { - String path = (String)it.next(); + for (String path : paths) { if (first) { first = false; } else { sb.append(File.pathSeparatorChar); } - sb.append(path); } @@ -178,8 +167,6 @@ private static String getClasspath(List paths) { return classpath; } - //////////////////////////////////////////////////////////////////////////// - /** * Configures the given JspC instance with the jsp-config properties * specified in the sun-web.xml of the web module represented by the @@ -196,36 +183,28 @@ private static void configureJspc(JspC jspc, WebBundleDescriptor wbd) { return; } - // START SJSAS 6384538 if (sunWebApp.sizeWebProperty() > 0) { WebProperty[] props = sunWebApp.getWebProperty(); - for (int i = 0; i < props.length; i++) { - String pName = props[i].getAttributeValue("name"); - String pValue = props[i].getAttributeValue("value"); + for (WebProperty prop : props) { + String pName = prop.getValue("name"); + String pValue = prop.getValue("value"); if (pName == null || pValue == null) { throw new IllegalArgumentException( "Missing sun-web-app property name or value"); } if ("enableTldValidation".equals(pName)) { jspc.setIsValidationEnabled( - Boolean.valueOf(pValue).booleanValue()); + Boolean.parseBoolean(pValue)); } } } - // END SJSAS 6384538 - // START SJSAS 6170435 - /* - * Configure JspC with the init params of the JspServlet - */ + // Configure JspC with the init params of the JspServlet Set set = wbd.getWebComponentDescriptors(); if (!set.isEmpty()) { - Iterator iterator = set.iterator(); - while (iterator.hasNext()) { - WebComponentDescriptor webComponentDesc = iterator.next(); + for (WebComponentDescriptor webComponentDesc : set) { if ("jsp".equals(webComponentDesc.getCanonicalName())) { - Enumeration en - = webComponentDesc.getInitializationParameters(); + Enumeration en = webComponentDesc.getInitializationParameters(); if (en != null) { while (en.hasMoreElements()) { InitializationParameter initP = en.nextElement(); @@ -236,19 +215,16 @@ private static void configureJspc(JspC jspc, WebBundleDescriptor wbd) { } } } - // END SJSAS 6170435 - /* - * Configure JspC with jsp-config properties from sun-web.xml, - * which override JspServlet init params of the same name. - */ + // Configure JspC with jsp-config properties from sun-web.xml, + // which override JspServlet init params of the same name. JspConfig jspConfig = sunWebApp.getJspConfig(); if (jspConfig == null) { return; } WebProperty[] props = jspConfig.getWebProperty(); for (int i=0; props!=null && i WSIMPORT_MODULES = Arrays.asList(new String[] { "jakarta.activation-api", "angus-activation", @@ -89,9 +89,8 @@ public class WebServiceTesterServlet extends HttpServlet { private static final Hashtable gsiClasses = new Hashtable<>(); private static final Hashtable ports = new Hashtable<>(); - // resources... - private static final LocalStringManagerImpl localStrings = - new LocalStringManagerImpl(WebServiceTesterServlet.class); + private static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl( + WebServiceTesterServlet.class); public static void invoke(HttpServletRequest request, HttpServletResponse response, WebServiceEndpoint endpoint) { @@ -99,7 +98,7 @@ public static void invoke(HttpServletRequest request, try { WebServiceTesterServlet servlet = new WebServiceTesterServlet(endpoint); - response.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding(UTF_8.name()); if (request.getMethod().equalsIgnoreCase("GET")) { servlet.doGet(request, response); } else { @@ -185,20 +184,12 @@ public void doGet(HttpServletRequest req, HttpServletResponse res) "Web Service Tester") + ""); - // Microsoft Internet Explorer does not handle