From b981b61eab9b1339ca807ad0dbba6b847ed0a004 Mon Sep 17 00:00:00 2001 From: lprimak Date: Wed, 4 Dec 2024 14:48:48 -0600 Subject: [PATCH] code cleanup --- .../enterprise/glassfish/web/WarHandler.java | 9 ++------ .../web/loader/WebappClassLoader.java | 22 +++++++++---------- .../annotation/impl/WarScanner.java | 2 +- .../deployment/archivist/WebArchivist.java | 12 +++++----- .../common/DeploymentContextImpl.java | 5 ----- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java b/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java index 927e3d2d3d1..0c6667a5f88 100644 --- a/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java +++ b/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates] package com.sun.enterprise.glassfish.web; @@ -56,7 +56,6 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; @@ -80,9 +79,6 @@ import org.glassfish.api.deployment.archive.ArchiveDetector; import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.deployment.common.DeploymentProperties; -import org.glassfish.deployment.common.DeploymentUtils; -import org.glassfish.deployment.common.InstalledLibrariesResolver; -import org.glassfish.internal.deployment.Deployment; import org.glassfish.loader.util.ASClassLoaderUtil; import org.glassfish.web.loader.LogFacade; import org.glassfish.web.loader.WebappClassLoader; @@ -132,8 +128,6 @@ public class WarHandler extends AbstractArchiveHandler { @Inject private ServerEnvironment serverEnvironment; - @Inject - private Deployment deployment; @Override public String getArchiveType() { @@ -197,6 +191,7 @@ public WebappClassLoader run() { WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application); configureLoaderAttributes(cloader, webXmlParser, base); configureLoaderProperties(cloader, webXmlParser, base); + configureContextXmlAttribute(cloader, base, context); try { diff --git a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java index fc367750fee..72e3e16851c 100644 --- a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java +++ b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java @@ -1176,7 +1176,16 @@ public boolean modified() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - if (isInternal()) { + Predicate matchesInternal = str -> str.matches(".*generated/.*__.*"); + boolean isInternal = false; + if (repositoryURLs != null) { + isInternal = Arrays.stream(repositoryURLs).map(URL::toString) + .filter(matchesInternal).findAny().isPresent(); + } + if (canonicalLoaderDir != null && matchesInternal.test(canonicalLoaderDir)) { + isInternal = true; + } + if (isInternal) { sb.append("(internal) "); } sb.append("WebappClassLoader (delegate="); @@ -2100,17 +2109,6 @@ public void stop() throws Exception { } } - public boolean isInternal() { - Predicate matchesInternal = str -> str.matches(".*generated/.*__.*"); - if (repositoryURLs != null) { - return Arrays.stream(repositoryURLs).map(URL::toString) - .filter(matchesInternal).findAny().isPresent(); - } - if (canonicalLoaderDir != null && matchesInternal.test(canonicalLoaderDir)) { - return true; - } - return false; - } /** * Used to periodically signal to the classloader to release diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/annotation/impl/WarScanner.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/annotation/impl/WarScanner.java index 64a4199d415..fb8e0536f3b 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/annotation/impl/WarScanner.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/annotation/impl/WarScanner.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates] package org.glassfish.web.deployment.annotation.impl; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java index 33f1f711527..eca18f0b6f6 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java @@ -43,10 +43,7 @@ import com.sun.enterprise.deploy.shared.ArchiveFactory; import com.sun.enterprise.deployment.Application; -import com.sun.enterprise.deployment.BundleDescriptor; import com.sun.enterprise.deployment.EarType; -import javassist.runtime.Desc; -import org.glassfish.deployment.common.Descriptor; import org.glassfish.deployment.common.InstalledLibrariesResolver; import org.glassfish.deployment.common.RootDeploymentDescriptor; import com.sun.enterprise.deployment.EjbBundleDescriptor; @@ -82,7 +79,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.File; -import java.net.URI; import java.nio.file.Path; import java.util.ArrayList; import java.util.Enumeration; @@ -92,7 +88,6 @@ import java.util.Map; import java.util.Set; import java.net.URL; -import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -381,7 +376,7 @@ protected void postAnnotationProcess(WebBundleDescriptorImpl descriptor, } } DeploymentUtils.getWarLibraryCache().putIfAbsent(wfDesc.getWarLibraryPath(), - new DeploymentUtils.WarLibraryDescriptor(wfDesc, computeTypes(wfDesc))); + new DeploymentUtils.WarLibraryDescriptor(wfDesc, filterTypesByWarLibrary(wfDesc))); } } else { super.readAnnotations(archive, wfDesc, localExtensions); @@ -423,8 +418,11 @@ protected void postAnnotationProcess(WebBundleDescriptorImpl descriptor, descriptor.addDefaultWebBundleDescriptor(defaultWebBundleDescriptor); } - private List computeTypes(WebFragmentDescriptor wfDesc) { + private List filterTypesByWarLibrary(WebFragmentDescriptor wfDesc) { Types types = deployment.getCurrentDeploymentContext().getTransientAppMetaData(Types.class.getName(), Types.class); + if (types == null) { + return List.of(); + } return types.getAllTypes().stream().filter(key -> key.wasDefinedIn( List.of(Path.of(wfDesc.getWarLibraryPath()).toUri()))).collect(Collectors.toList()); } diff --git a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentContextImpl.java b/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentContextImpl.java index f4c49fa6ee1..d3552986c29 100644 --- a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentContextImpl.java +++ b/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentContextImpl.java @@ -57,7 +57,6 @@ import org.glassfish.loader.util.ASClassLoaderUtil; import java.lang.ref.WeakReference; -import java.nio.file.Path; import java.util.*; import java.util.logging.Logger; import java.io.File; @@ -74,10 +73,6 @@ import com.sun.enterprise.util.io.FileUtils; import fish.payara.nucleus.hotdeploy.ApplicationState; import fish.payara.nucleus.hotdeploy.HotDeployService; -import java.io.Closeable; -import java.util.logging.Level; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINEST; import org.glassfish.api.deployment.DeployCommandParameters;