Skip to content

Commit

Permalink
Merge pull request #5559 from eclipse/jetty-9.4.x-5555-NPE-NamedFilte…
Browse files Browse the repository at this point in the history
…rMapping

Jetty 9.4.x 5555 npe named filter mapping
  • Loading branch information
joakime committed Nov 2, 2020
2 parents 12f3c45 + 4c49ca5 commit 981b50d
Showing 1 changed file with 5 additions and 16 deletions.
Expand Up @@ -521,21 +521,8 @@ public void doHandle(String target, Request baseRequest, HttpServletRequest requ
FilterChain chain = null;

// find the servlet
if (target.startsWith("/"))
{
if (servletHolder != null && _filterMappings != null && _filterMappings.length > 0)
chain = getFilterChain(baseRequest, target, servletHolder);
}
else
{
if (servletHolder != null)
{
if (_filterMappings != null && _filterMappings.length > 0)
{
chain = getFilterChain(baseRequest, null, servletHolder);
}
}
}
if (servletHolder != null && _filterMappings != null && _filterMappings.length > 0)
chain = getFilterChain(baseRequest, target.startsWith("/") ? target : null, servletHolder);

if (LOG.isDebugEnabled())
LOG.debug("chain={}", chain);
Expand Down Expand Up @@ -593,6 +580,7 @@ public MappedResource<ServletHolder> getMappedServlet(String target)

protected FilterChain getFilterChain(Request baseRequest, String pathInContext, ServletHolder servletHolder)
{
Objects.requireNonNull(servletHolder);
String key = pathInContext == null ? servletHolder.getName() : pathInContext;
int dispatch = FilterMapping.dispatch(baseRequest.getDispatcherType());

Expand All @@ -608,7 +596,7 @@ protected FilterChain getFilterChain(Request baseRequest, String pathInContext,
// The mappings lists have been reversed to make this simple and fast.
FilterChain chain = null;

if (servletHolder != null && _filterNameMappings != null && !_filterNameMappings.isEmpty())
if (_filterNameMappings != null && !_filterNameMappings.isEmpty())
{
if (_wildFilterNameMappings != null)
for (FilterMapping mapping : _wildFilterNameMappings)
Expand Down Expand Up @@ -1626,6 +1614,7 @@ static class ChainEnd implements FilterChain

ChainEnd(ServletHolder holder)
{
Objects.requireNonNull(holder);
_servletHolder = holder;
}

Expand Down

0 comments on commit 981b50d

Please sign in to comment.