Merge pull request #10902 from jetty/jetty-12.0.x-addContainerResource

do not add duplicate jars to MetaData containerResources
This commit is contained in:
Lachlan 2023-11-23 08:36:12 +11:00 committed by GitHub
commit 4a91cb7464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -25,6 +25,7 @@ import java.util.Objects;
import jakarta.servlet.ServletContext;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.Resources;
import org.eclipse.jetty.util.thread.AutoLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -714,8 +715,13 @@ public class MetaData
public void addContainerResource(Resource jar)
{
Objects.requireNonNull(jar);
_orderedContainerResources.add(jar);
if (!Resources.isReadable(jar))
throw new IllegalArgumentException("Resource is not readable: " + jar);
if (!_orderedContainerResources.contains(jar))
_orderedContainerResources.add(jar);
else
LOG.warn("Duplicate Container Resource {}", jar);
}
public void setWebInfClassesResources(List<Resource> dirs)

View File

@ -25,6 +25,7 @@ import java.util.Objects;
import jakarta.servlet.ServletContext;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.Resources;
import org.eclipse.jetty.util.thread.AutoLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -714,7 +715,13 @@ public class MetaData
public void addContainerResource(Resource jar)
{
_orderedContainerResources.add(jar);
if (!Resources.isReadable(jar))
throw new IllegalArgumentException("Resource is not readable: " + jar);
if (!_orderedContainerResources.contains(jar))
_orderedContainerResources.add(jar);
else
LOG.warn("Duplicate Container Resource {}", jar);
}
public void setWebInfClassesResources(List<Resource> dirs)