Skip to content

Commit

Permalink
Fixes piranhacloud#4478 - Add logging to DefaultInvocationFinder for …
Browse files Browse the repository at this point in the history
…debugging purposes
  • Loading branch information
mnriem committed Jan 9, 2025
1 parent b2d0f6f commit 96c69cd
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import jakarta.servlet.FilterChain;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletException;
import java.lang.System.Logger;
import static java.lang.System.Logger.Level.TRACE;

/**
* The invocation finder tries to find a servlet invocation matching a request
Expand All @@ -57,12 +59,16 @@
* Invocations returned by this finder take into account the various mappings,
* filters, welcome files and the default servlet.
*
*
* @author Arjan Tijms
*
*/
public class DefaultInvocationFinder {

/**
* Stores the logger.
*/
private static final Logger LOGGER
= System.getLogger(DefaultInvocationFinder.class.getName());

/**
* Stores the web application.
*/
Expand Down Expand Up @@ -101,6 +107,12 @@ public DefaultServletInvocation findServletInvocationByPath(String servletPath,
* @throws ServletException when a Servlet error occurs.
*/
public DefaultServletInvocation findServletInvocationByPath(DispatcherType dispatcherType, String servletPath, String pathInfo) throws IOException, ServletException {
if (LOGGER.isLoggable(TRACE)) {
LOGGER.log(TRACE, "Find servlet invocation by path");
LOGGER.log(TRACE, "DispatcherType: {0}", dispatcherType.name());
LOGGER.log(TRACE, "Servlet path: {0}", servletPath);
LOGGER.log(TRACE, "Path info: {0}", pathInfo);
}
DefaultServletInvocation servletInvocation = getDirectServletInvocationByPath(servletPath, pathInfo);

if (servletInvocation == null) {
Expand Down Expand Up @@ -143,14 +155,14 @@ public DefaultServletInvocation addFilters(DispatcherType dispatcherType, Defaul
return servletInvocation;
}

List<FilterEnvironment> filterEnvironments =
findFilterEnvironments(
dispatcherType,
// Look at the servletInvocation if there is one, as a welcome file can be set
// that differs from the request path
servletInvocation == null ? servletPath : servletInvocation.getServletPath(),
servletInvocation == null ? pathInfo : servletInvocation.getPathInfo(),
servletInvocation == null ? null : servletInvocation.getServletName());
List<FilterEnvironment> filterEnvironments
= findFilterEnvironments(
dispatcherType,
// Look at the servletInvocation if there is one, as a welcome file can be set
// that differs from the request path
servletInvocation == null ? servletPath : servletInvocation.getServletPath(),
servletInvocation == null ? pathInfo : servletInvocation.getPathInfo(),
servletInvocation == null ? null : servletInvocation.getServletName());

if (filterEnvironments != null) {
if (servletInvocation == null) {
Expand Down

0 comments on commit 96c69cd

Please sign in to comment.