Skip to content

Commit

Permalink
Issue #7891 - Fixing compilation issues
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed May 11, 2022
1 parent 3085e71 commit 498b5c3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
Expand Up @@ -150,6 +150,7 @@ public MatchedResource<E> getMatched(String path)
// Search all the mappings
for (MappedResource<E> mr : _mappings)
{
boolean skipMatch = false;
PathSpecGroup group = mr.getPathSpec().getGroup();
if (group != lastGroup)
{
Expand All @@ -161,6 +162,7 @@ public MatchedResource<E> getMatched(String path)
if (_optimizedExact)
{
int i = path.length();

final Trie<MappedResource<E>> exact_map = _exactMap;
while (i >= 0)
{
Expand All @@ -170,15 +172,13 @@ public MatchedResource<E> getMatched(String path)

matchedPath = candidate.getPathSpec().matched(path);
if (matchedPath != null)
{
return new MatchedResource<>(candidate.getResource(), candidate.getPathSpec(), matchedPath);
i = candidate.getPathSpec().getDeclaration().length() - 1;
}
i--;
}
}
else
{
matchedPath = mr.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(mr.getResource(), mr.getPathSpec(), matchedPath);
// If we reached here, there's NO optimized EXACT Match possible, skip simple match below
skipMatch = true;
}
break;
}
Expand All @@ -198,14 +198,10 @@ public MatchedResource<E> getMatched(String path)
matchedPath = candidate.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(candidate.getResource(), candidate.getPathSpec(), matchedPath);
i = candidate.getPathSpec().getPrefix().length() - 1;
i--;
}
}
else
{
matchedPath = mr.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(mr.getResource(), mr.getPathSpec(), matchedPath);
// If we reached here, there's NO optimized PREFIX Match possible, skip simple match below
skipMatch = true;
}
break;
}
Expand All @@ -226,12 +222,8 @@ public MatchedResource<E> getMatched(String path)
if (matchedPath != null)
return new MatchedResource<>(candidate.getResource(), candidate.getPathSpec(), matchedPath);
}
}
else
{
matchedPath = mr.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(mr.getResource(), mr.getPathSpec(), matchedPath);
// If we reached here, there's NO optimized SUFFIX Match possible, skip simple match below
skipMatch = true;
}
break;
}
Expand All @@ -240,9 +232,13 @@ public MatchedResource<E> getMatched(String path)
}
}

matchedPath = mr.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(mr.getResource(), mr.getPathSpec(), matchedPath);
// Only perform simple match if optimized match lets us
if (!skipMatch)
{
matchedPath = mr.getPathSpec().matched(path);
if (matchedPath != null)
return new MatchedResource<>(mr.getResource(), mr.getPathSpec(), matchedPath);
}

lastGroup = group;
}
Expand Down
Expand Up @@ -173,7 +173,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
String path = URIUtil.addPaths(servletPath, servlet);
MatchedResource<ServletHolder> entry = _servletHandler.getMatchedServlet(path);

if (entry != null && !entry.getMappedResource().equals(_invokerEntry.getMappedResource()))
if (entry != null && !entry.getResource().equals(_invokerEntry.getResource()))
{
// Use the holder
holder = entry.getResource();
Expand Down
Expand Up @@ -377,7 +377,10 @@ public FilterHolder[] getFilters()
public MappedResource<ServletHolder> getHolderEntry(String target)
{
if (target.startsWith("/"))
return getMatchedServlet(target).getMappedResource();
{
MatchedResource<ServletHolder> matchedResource = getMatchedServlet(target);
return new MappedResource<>(matchedResource.getPathSpec(), matchedResource.getResource());
}
return null;
}

Expand Down Expand Up @@ -474,8 +477,8 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque

if (matched.getPathSpec() != null)
{
String servletPath = matched.getMatchedPath().getPathMatch();
String pathInfo = matched.getMatchedPath().getPathInfo();
String servletPath = matched.getPathMatch();
String pathInfo = matched.getPathInfo();

if (DispatcherType.INCLUDE.equals(type))
{
Expand Down Expand Up @@ -577,8 +580,7 @@ public MatchedResource<ServletHolder> getMatchedServlet(String target)
ServletHolder holder = _servletNameMap.get(target);
if (holder == null)
return null;
MappedResource<ServletHolder> mappedResource = new MappedResource<>(null, holder);
return new MatchedResource<>(mappedResource, MatchedPath.EMPTY);
return new MatchedResource<>(holder, null, MatchedPath.EMPTY);
}

/**
Expand All @@ -591,7 +593,8 @@ public MatchedResource<ServletHolder> getMatchedServlet(String target)
@Deprecated
public MappedResource<ServletHolder> getMappedServlet(String target)
{
return getMatchedServlet(target).getMappedResource();
MatchedResource<ServletHolder> matchedResource = getMatchedServlet(target);
return new MappedResource<>(matchedResource.getPathSpec(), matchedResource.getResource());
}

protected FilterChain getFilterChain(Request baseRequest, String pathInContext, ServletHolder servletHolder)
Expand Down

0 comments on commit 498b5c3

Please sign in to comment.