Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jetty#11789 run list distinct on the generated resources list during startup #11790

Open
wants to merge 2 commits into
base: jetty-12.0.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import jakarta.servlet.ServletContext;
import org.eclipse.jetty.util.URIUtil;
Expand Down Expand Up @@ -485,7 +486,8 @@ public void resolve(WebAppContext context)
resources.add(null); //always apply annotations with no resource first
resources.addAll(_orderedContainerResources); //next all annotations from container path
resources.addAll(_webInfClasses); //next everything from web-inf classes
resources.addAll(getWebInfResources(isOrdered())); //finally annotations (in order) from webinf path
resources.addAll(getWebInfResources(isOrdered())); //finally annotations (in order) from webinf path
resources = resources.stream().distinct().collect(Collectors.toList()); // filter out possible duplicates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janbartel @jackeri I'm not opposed to defensively removing duplicates, but I think we should warn. Somethine like:

Suggested change
resources = resources.stream().distinct().collect(Collectors.toList()); // filter out possible duplicates
List<Resource> nodups = resources.stream().distinct().collect(Collectors.toList()); // filter out possible duplicates
if (nodups.length() < resources.length())
{
LOG.warning("Duplicate jars: " + resources);
resources = nodups;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on this, as it is an error to have duplicates on the classpath, which is where this derives from.


for (Resource r : resources)
{
Expand Down