From adadefd6f8696eeb8f8acdfcaada7f8ef6b50312 Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Wed, 17 Feb 2010 23:09:12 +0000 Subject: [PATCH] SOLR-1679: make SolrCore.execute pay attention to log level before building up big log message strings git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@911216 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 +++ src/java/org/apache/solr/core/SolrCore.java | 33 +++++++++++++-------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1764d10af21..11e7e0b7dd1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -91,6 +91,10 @@ New Features Optimizations ---------------------- +* SOLR-1679: Don't build up string messages in SolrCore.execute unless they + are necessary for the current log level. + (Fuad Efendi and hossman) + Bug Fixes ---------------------- diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index dee33d820c1..49e72c34fe9 100644 --- a/src/java/org/apache/solr/core/SolrCore.java +++ b/src/java/org/apache/solr/core/SolrCore.java @@ -1299,29 +1299,38 @@ public final class SolrCore implements SolrInfoMBean { public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) { if (handler==null) { - log.warn(logid+"Null Request Handler '" + req.getParams().get(CommonParams.QT) +"' :" + req); - throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Null Request Handler '" + req.getParams().get(CommonParams.QT) + "'", true); + String msg = "Null Request Handler '" + + req.getParams().get(CommonParams.QT) + "'"; + + if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req); + + throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg, true); } // setup response header and handle request final NamedList responseHeader = new SimpleOrderedMap(); rsp.add("responseHeader", responseHeader); + + // toLog is a local ref to the same NamedList used by the request NamedList toLog = rsp.getToLog(); - //toLog.add("core", getName()); + // for back compat, we set these now just in case other code + // are expecting them during handleRequest toLog.add("webapp", req.getContext().get("webapp")); toLog.add("path", req.getContext().get("path")); toLog.add("params", "{" + req.getParamString() + "}"); + handler.handleRequest(req,rsp); setResponseHeaderValues(handler,req,rsp); - StringBuilder sb = new StringBuilder(); - for (int i=0; i