Skip to content

Apache Lucene open-source search software

SOLR-12353: SolrDispatchFilter expensive non-conditional debug line degrades performance

Erick Erickson5fd55d77e9f5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b18d9af8544..cbc8d19b4aa 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -86,6 +86,8 @@ Other Changes
* SOLR-13944: Remove redundant checks in SpellCheckCollator and add tests for spellcheck with collapse
(Stefan, Munendra S N, Tomas Eduardo Fernandez Lobbe)
+* SOLR-12353: SolrDispatchFilter expensive non-conditional debug line degrades performance (Pascal Proulx via Erick Erickson)
+
================== 8.5.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 8123f478695..5222a6f0ad2 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -146,7 +146,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {
public void init(FilterConfig config) throws ServletException
{
SSLConfigurationsFactory.current().init();
- log.trace("SolrDispatchFilter.init(): {}", this.getClass().getClassLoader());
+ if (log.isTraceEnabled()) {
+ log.trace("SolrDispatchFilter.init(): {}", this.getClass().getClassLoader());
+ }
CoreContainer coresInit = null;
try{
@@ -161,7 +163,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}
String logLevel = System.getProperty(SOLR_LOG_LEVEL);
if (logLevel != null) {
- log.info("Log level override, property solr.log.level=" + logLevel);
+ log.info("Log level override, property solr.log.level={}", logLevel);
StartupLoggingUtils.changeLogLevel(logLevel);
}
@@ -184,7 +186,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {
SolrPaths.ensureUserFilesDataDir(solrHomePath);
this.httpClient = coresInit.getUpdateShardHandler().getDefaultHttpClient();
setupJvmMetrics(coresInit);
- log.debug("user.dir=" + System.getProperty("user.dir"));
+ if (log.isDebugEnabled()) {
+ log.debug("user.dir={}", System.getProperty("user.dir"));
+ }
}
catch( Throwable t ) {
// catch this so our filter still works
@@ -485,21 +489,21 @@ public class SolrDispatchFilter extends BaseSolrFilter {
// /admin/info/key must be always open. see SOLR-9188
String requestPath = ServletUtils.getPathAfterContext(request);
if (PublicKeyHandler.PATH.equals(requestPath)) {
- if (log.isDebugEnabled())
- log.debug("Pass through PKI authentication endpoint");
+ log.debug("Pass through PKI authentication endpoint");
return true;
}
// /solr/ (Admin UI) must be always open to allow displaying Admin UI with login page
if ("/solr/".equals(requestPath) || "/".equals(requestPath)) {
- if (log.isDebugEnabled())
- log.debug("Pass through Admin UI entry point");
+ log.debug("Pass through Admin UI entry point");
return true;
}
String header = request.getHeader(PKIAuthenticationPlugin.HEADER);
if (header != null && cores.getPkiAuthenticationPlugin() != null)
authenticationPlugin = cores.getPkiAuthenticationPlugin();
try {
- log.debug("Request to authenticate: {}, domain: {}, port: {}", request, request.getLocalName(), request.getLocalPort());
+ if (log.isDebugEnabled()) {
+ log.debug("Request to authenticate: {}, domain: {}, port: {}", request, request.getLocalName(), request.getLocalPort());
+ }
// upon successful authentication, this should call the chain's next filter.
requestContinues = authenticationPlugin.authenticate(request, response, (req, rsp) -> {
isAuthenticated.set(true);