Skip to content

Commit

Permalink
Suppress handler mapping logging for introspector
Browse files Browse the repository at this point in the history
Closes gh-30349
  • Loading branch information
rstoyanchev committed Sep 20, 2023
1 parent 2530efd commit 0f7c406
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
implements HandlerMapping, Ordered, BeanNameAware {

final static String SUPPRESS_LOGGING_ATTRIBUTE = AbstractHandlerMapping.class.getName() + ".SUPPRESS_LOGGING";


/** Dedicated "hidden" logger for request mappings. */
protected final Log mappingsLogger =
LogDelegateFactory.getHiddenLog(HandlerMapping.class.getName() + ".Mappings");
Expand Down Expand Up @@ -520,11 +523,13 @@ public final HandlerExecutionChain getHandler(HttpServletRequest request) throws

HandlerExecutionChain executionChain = getHandlerExecutionChain(handler, request);

if (logger.isTraceEnabled()) {
logger.trace("Mapped to " + handler);
}
else if (logger.isDebugEnabled() && !DispatcherType.ASYNC.equals(request.getDispatcherType())) {
logger.debug("Mapped to " + executionChain.getHandler());
if (request.getAttribute(SUPPRESS_LOGGING_ATTRIBUTE) == null) {
if (logger.isTraceEnabled()) {
logger.trace("Mapped to " + handler);
}
else if (logger.isDebugEnabled() && !DispatcherType.ASYNC.equals(request.getDispatcherType())) {
logger.debug("Mapped to " + executionChain.getHandler());
}
}

if (hasCorsConfigurationSource(handler) || CorsUtils.isPreFlightRequest(request)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ private static class AttributesPreservingRequest extends HttpServletRequestWrapp
AttributesPreservingRequest(HttpServletRequest request) {
super(request);
this.attributes = initAttributes(request);
this.attributes.put(AbstractHandlerMapping.SUPPRESS_LOGGING_ATTRIBUTE, Boolean.TRUE);
}

private Map<String, Object> initAttributes(HttpServletRequest request) {
Expand Down

0 comments on commit 0f7c406

Please sign in to comment.