Skip to content

Apache Lucene open-source search software

LUCENE-7788: fail precommit on unparameterised log messages and examine for wasted work/objects

Erick Erickson960610a615a2
diff --git a/gradle/validation/validate-log-calls.gradle b/gradle/validation/validate-log-calls.gradle
index 20b000d615a..a44a25e0d01 100644
--- a/gradle/validation/validate-log-calls.gradle
+++ b/gradle/validation/validate-log-calls.gradle
@@ -23,33 +23,42 @@ import static java.util.concurrent.TimeUnit.SECONDS
// either in CPU or unnecessary object creation
configure(rootProject) {
+}
- allprojects {
-
+allprojects {
+ plugins.withType(JavaPlugin) {
task validateLogCalls(type: ValidateLogCallsTask) {
description "Checks that log calls are either validated or conform to efficient patterns."
group "verification"
doFirst {
if (project.hasProperty('srcDir')) {
- srcDir = project.getProperty('srcDir')
+ srcDir.addAll(project.getProperty('srcDir').split(','))
} else { // Remove this later, make it optional
//nocommit
throw new BuildException(String.format(Locale.ENGLISH,
- '''Until we get all the calls cleaned up, you MUST specify -PsrcDir=relative_path, e.g.
- "-PsrcDir=solr/core/src/java/org/apache/solr/core". This task will recursively check all
- "*.java" files under that directory'''))
+ '''Until we get all the calls cleaned up, you MUST specify -PsrcDir=relative_path, e.g.
+ "-PsrcDir=solr/core/src/java/org/apache/solr/core". This task will recursively check all
+ "*.java" files under that directory'''))
}
checkPlus = Boolean.valueOf(propertyOrDefault('checkPlus', 'false'))
}
}
}
+// // Attach ecjLint to check.
+// check.dependsOn ecjLint
+ // What does the below mean?
+// // Each validation task should be attached to check but make sure
+// // precommit() as a whole is a dependency on rootProject.check
+// check.dependsOn precommit
+
}
+//}
class ValidateLogCallsTask extends DefaultTask {
@Input
- String srcDir = ""
+ List<String> srcDir = []
@Input
boolean checkPlus
@@ -94,6 +103,17 @@ class ValidateLogCallsTask extends DefaultTask {
, "solr/core/src/java/org/apache/solr/uninverting"
, "solr/core/src/java/org/apache/solr/update"
, "solr/core/src/java/org/apache/solr/util"
+ , "solr/solrj/src/java/org/apache/solr/common/util"
+ , "solr/solrj/src/java/org/apache/solr/common/cloud" // 18
+ , "solr/solrj/src/java/org/apache/solr/client/solrj/impl" // 27
+ , "solr/solrj/src/java/org/apache/solr/client/solrj/io" // 8
+ , "solr/solrj/src/java/org/apache/solr/client/solrj/cloud" // 26
+ , "solr/solrj/src/java/org/apache/solr/client/solrj/routing" //2
+ , "solr/solrj/src/test/org/apache/solr/common/cloud" //1
+ , "solr/solrj/src/test/org/apache/solr/client/solrj/impl" //15
+ , "solr/solrj/src/test/org/apache/solr/client/solrj" //34
+ , "solr/solrj/src/test/org/apache/solr/client/solrj/io/stream" // 1
+ , "solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling" //4
]
//nocommit REMOVE ME! Really! and the check for bare parens. Several times I've put in () when I meant {} and only
@@ -151,7 +171,7 @@ class ValidateLogCallsTask extends DefaultTask {
// If the line has been explicitly checked, skip it.
if (line.replaceAll("\\s", "").toLowerCase().contains("//logok")) {
- return violation
+ return
}
// Strip all of the comments, things in quotes and the like.
def level = ""
@@ -207,18 +227,10 @@ class ValidateLogCallsTask extends DefaultTask {
violation = true
}
if (violation) {
- reportViolation(String.format("Suspicious logging call, Parameterize or surround with 'if (log.is*Enabled) {..%s %s:%d"
- , System.lineSeparator, file.getAbsolutePath(), lineNumber))
-// reportViolation(String.format("Suspicious logging call File: '%s' line: '%d' log message: '%s' parent path: '%s'. Parameterize or surround with 'if (log.is*Enabled) {... stripped: '%s'"
-// , file.name
-// , lineNumber
-// , line
-// , file.getParentFile().getAbsolutePath()
-// , stripped
-// ))
-// reportViolation(String.format("%s:%d", file.getAbsolutePath(), lineNumber))
+ reportViolation(String.format("Suspicious logging call, Parameterize and possibly surround with 'if (log.is*Enabled) {..}'. Help at: 'gradlew helpValidateLogCalls' %s %s:%d"
+ , System.lineSeparator, file.getAbsolutePath(), lineNumber))
}
- return violation
+ return
}
@@ -288,19 +300,20 @@ class ValidateLogCallsTask extends DefaultTask {
case 1:
break;
case 2:
- foundViolation = (checkLogLine(file, sb.toString(), lineNumber, prevLine)) ? true : foundViolation
+ checkLogLine(file, sb.toString(), lineNumber, prevLine)
state = 0
break;
default:
break;
}
}
- return foundViolation
+ return
}
@TaskAction
def checkLogLines() {
- dirsToCheck.add(srcDir)
+// println srcDir
+ dirsToCheck.addAll(srcDir)
//nocommit. This is here to check 8x on another branch since I can't run Gradle
// over 8x. Used periodically as a sanity check.
@@ -314,26 +327,31 @@ class ValidateLogCallsTask extends DefaultTask {
// }
// }
+// new File("/Users/Erick/apache/SolrEOEFork").traverse(type: groovy.io.FileType.FILES, nameFilter: ~/.*\.java/) { File it ->
+// if (checkFile(it)) {
+// println(it.getAbsolutePath())
+// }
+// }
+//
+//nocommit
+// println project
+
+ // This is the real stuff
project.sourceSets.each { srcSet ->
srcSet.java.each { f ->
- if (dirsToCheck.any {
+ if (srcDir.contains("all")) {
+ checkFile(f)
+ } else if (dirsToCheck.any {
f.getCanonicalPath().contains(it)
}) {
- if (checkFile(f)) {
- // nocommit. This just makes it much easier to get to the files during this mass migration!
- println(f.getAbsolutePath())
- }
+ checkFile(f)
}
-// nocommit move
-// this to project based whenever
-// if (srcDir != null && f.getCanonicalPath().contains(srcDir)) {
-// checkFile(f)
-// }
}
}
+
if (errsFound > 0) {
throw new BuildException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
- errsFound, violations.join(', ')));
+ errsFound, violations.join(', ')));
}
}
}
diff --git a/help/validateLogCalls.txt b/help/validateLogCalls.txt
index 1d28e99587c..dd5f9e09115 100644
--- a/help/validateLogCalls.txt
+++ b/help/validateLogCalls.txt
@@ -54,4 +54,6 @@ from there.
Until we get all the calls cleaned up, you MUST specify -PsrcDir=relative_path,
e.g. '-PsrcDir=solr/core/src/java/org/apache/solr/core'. This task will
- recursively check all '*.java. files under that directory.
+ recursively check all '*.java. files under that directory. Actually, it
+ just checks any file whose AbsolutePath contains the specification. May be
+ comma-delimited.
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
index 015c901a753..84baeeb8144 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
@@ -151,7 +151,7 @@ public class SocketProxy {
synchronized (this.connections) {
connections = new ArrayList<Bridge>(this.connections);
}
- log.warn("Closing " + connections.size()+" connections to: "+getUrl()+", target: "+target);
+ log.warn("Closing {} connections to: {}, target: {}", connections.size(), getUrl(), target);
for (Bridge con : connections) {
closeConnection(con);
}
@@ -167,7 +167,9 @@ public class SocketProxy {
synchronized (this.connections) {
connections = new ArrayList<Bridge>(this.connections);
}
- log.info("halfClose, numConnections=" + connections.size());
+ if (log.isInfoEnabled()) {
+ log.info("halfClose, numConnections= {}", connections.size());
+ }
for (Bridge con : connections) {
halfCloseConnection(con);
}
@@ -182,7 +184,9 @@ public class SocketProxy {
* called after a close to restart the acceptor on the same port
*/
public void reopen() {
- log.info("Re-opening connectivity to "+getUrl());
+ if (log.isInfoEnabled()) {
+ log.info("Re-opening connectivity to {}", getUrl());
+ }
try {
if (proxyUrl == null) {
throw new IllegalStateException("Can not call open before open(URI uri).");
@@ -195,7 +199,9 @@ public class SocketProxy {
serverSocket.bind(new InetSocketAddress(proxyUrl.getPort()));
doOpen();
} catch (Exception e) {
- log.debug("exception on reopen url:" + getUrl(), e);
+ if (log.isDebugEnabled()) {
+ log.debug("exception on reopen url:{} ", getUrl(), e);
+ }
}
}
@@ -205,7 +211,9 @@ public class SocketProxy {
*/
public void pause() {
synchronized (connections) {
- log.info("pause, numConnections=" + connections.size());
+ if (log.isInfoEnabled()) {
+ log.info("pause, numConnections={}", connections.size());
+ }
acceptor.pause();
for (Bridge con : connections) {
con.pause();
@@ -218,7 +226,9 @@ public class SocketProxy {
*/
public void goOn() {
synchronized (connections) {
- log.info("goOn, numConnections=" + connections.size());
+ if (log.isInfoEnabled()) {
+ log.info("goOn, numConnections={}", connections.size());
+ }
for (Bridge con : connections) {
con.goOn();
}
@@ -230,7 +240,7 @@ public class SocketProxy {
try {
c.close();
} catch (Exception e) {
- log.debug("exception on close of: " + c, e);
+ log.debug("exception on close of: {}", c, e);
}
}
@@ -238,7 +248,7 @@ public class SocketProxy {
try {
c.halfClose();
} catch (Exception e) {
- log.debug("exception on half close of: " + c, e);
+ log.debug("exception on half close of: {}", c, e);
}
}
@@ -282,8 +292,9 @@ public class SocketProxy {
sendSocket.connect(new InetSocketAddress(target.getHost(), target
.getPort()));
linkWithThreads(receiveSocket, sendSocket);
- log.info("proxy connection " + sendSocket + ", receiveBufferSize="
- + sendSocket.getReceiveBufferSize());
+ if (log.isInfoEnabled()) {
+ log.info("proxy connection {}, receiveBufferSize={}", sendSocket, sendSocket.getReceiveBufferSize());
+ }
}
public void goOn() {
@@ -344,10 +355,10 @@ public class SocketProxy {
src.setSoTimeout(PUMP_SOCKET_TIMEOUT_MS);
} catch (SocketException e) {
if (e.getMessage().equals("Socket is closed")) {
- log.warn("Failed to set socket timeout on "+src+" due to: "+e);
+ log.warn("Failed to set socket timeout on {} due to: ", src, e);
return;
}
- log.error("Failed to set socket timeout on "+src+" due to: "+e);
+ log.error("Failed to set socket timeout on {} due to ",src, e);
throw new RuntimeException(e);
}
@@ -361,11 +372,11 @@ public class SocketProxy {
try {
len = in.read(buf);
} catch (SocketTimeoutException ste) {
- log.warn(ste+" when reading from "+src);
+ log.warn("Error when reading from {}", src, ste);
}
if (len == -1) {
- log.debug("read eof from:" + src);
+ log.debug("read eof from: {}", src);
break;
}
pause.get().await();
@@ -373,7 +384,9 @@ public class SocketProxy {
out.write(buf, 0, len);
}
} catch (Exception e) {
- log.debug("read/write failed, reason: " + e.getLocalizedMessage());
+ if (log.isDebugEnabled()) {
+ log.debug("read/write failed, reason: {}", e.getLocalizedMessage());
+ }
try {
if (!receiveSocket.isClosed()) {
// for halfClose, on read/write failure if we close the
@@ -386,14 +399,14 @@ public class SocketProxy {
try {
in.close();
} catch (Exception exc) {
- log.debug(exc+" when closing InputStream on socket: "+src);
+ log.debug("Error when closing InputStream on socket: {}", src, exc);
}
}
if (out != null) {
try {
out.close();
} catch (Exception exc) {
- log.debug(exc+" when closing OutputStream on socket: "+destination);
+ log.debug("{} when closing OutputStream on socket: {}", exc, destination);
}
}
}
@@ -432,15 +445,18 @@ public class SocketProxy {
if (receiveBufferSize > 0) {
source.setReceiveBufferSize(receiveBufferSize);
}
- log.info("accepted " + source + ", receiveBufferSize:"
- + source.getReceiveBufferSize());
+ if (log.isInfoEnabled()) {
+ log.info("accepted {}, receiveBufferSize: {}", source, source.getReceiveBufferSize());
+ }
synchronized (connections) {
connections.add(new Bridge(source, target));
}
} catch (SocketTimeoutException expected) {}
}
} catch (Exception e) {
- log.debug("acceptor: finished for reason: " + e.getLocalizedMessage());
+ if (log.isDebugEnabled()) {
+ log.debug("acceptor: finished for reason: {}", e.getLocalizedMessage());
+ }
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
index 3448661784b..ec68c023cc6 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Policy.java
@@ -338,7 +338,7 @@ public class Policy implements MapWriter {
clusterPreferences,
lastComparison[0].node,
lastComparison[1].node,
- Utils.writeJson(m, new StringWriter(), true).toString(), exc.toString());
+ Utils.writeJson(m, new StringWriter(), true).toString(), exc.toString()); // logOK
} catch (IOException e1) {
//
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PolicyHelper.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PolicyHelper.java
index 71870118db8..815e8983309 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PolicyHelper.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/PolicyHelper.java
@@ -153,7 +153,7 @@ public class PolicyHelper {
}
}
} catch (IOException e) {
- log.warn("Exception while reading disk free metric values for nodes to be used for collection: " + collName, e);
+ log.warn("Exception while reading disk free metric values for nodes to be used for collection: {}", collName, e);
}
@@ -180,8 +180,9 @@ public class PolicyHelper {
if (op == null) {
String errorId = "AutoScaling.error.diagnostics." + System.nanoTime();
Policy.Session sessionCopy = suggester.session;
- log.error("errorId : " + errorId + " " +
- handleExp(log, "", () -> Utils.writeJson(getDiagnostics(sessionCopy), new StringWriter(), true).toString()));
+ log.error("errorId : {} {}", errorId
+ , handleExp(log, "", () -> Utils.writeJson(getDiagnostics(sessionCopy), new StringWriter(), true).toString())
+ ); // logOK
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, " No node can satisfy the rules " +
Utils.toJSONString(Utils.getDeepCopy(session.expandedClauses, 4, true) + " More details from logs in node : "
@@ -359,9 +360,11 @@ public class PolicyHelper {
public static void logState(SolrCloudManager cloudManager, Suggester suggester) {
if (log.isTraceEnabled()) {
try {
- log.trace("LOGSTATE: {}",
- Utils.writeJson(loggingInfo(cloudManager.getDistribStateManager().getAutoScalingConfig().getPolicy(), cloudManager, suggester),
- new StringWriter(), true).toString());
+ if (log.isTraceEnabled()) {
+ log.trace("LOGSTATE: {}",
+ Utils.writeJson(loggingInfo(cloudManager.getDistribStateManager().getAutoScalingConfig().getPolicy(), cloudManager, suggester),
+ new StringWriter(), true));
+ }
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -430,9 +433,12 @@ public class PolicyHelper {
TimeSource timeSource = sessionWrapper.session != null ? sessionWrapper.session.cloudManager.getTimeSource() : TimeSource.NANO_TIME;
synchronized (lockObj) {
sessionWrapper.status = Status.EXECUTING;
- log.debug("returnSession, curr-time {} sessionWrapper.createTime {}, this.sessionWrapper.createTime {} ", time(timeSource, MILLISECONDS),
- sessionWrapper.createTime,
- this.sessionWrapper.createTime);
+ if (log.isDebugEnabled()) {
+ log.debug("returnSession, curr-time {} sessionWrapper.createTime {}, this.sessionWrapper.createTime {} "
+ , time(timeSource, MILLISECONDS),
+ sessionWrapper.createTime,
+ this.sessionWrapper.createTime);
+ }
if (sessionWrapper.createTime == this.sessionWrapper.createTime) {
//this session was used for computing new operations and this can now be used for other
// computing
@@ -466,13 +472,18 @@ public class PolicyHelper {
return sessionWrapper;
} else {
//status= COMPUTING it's being used for computing. computing is
- log.debug("session being used. waiting... current time {} ", time(timeSource, MILLISECONDS));
+ if (log.isDebugEnabled()) {
+ log.debug("session being used. waiting... current time {} ", time(timeSource, MILLISECONDS));
+ }
try {
lockObj.wait(10 * 1000);//wait for a max of 10 seconds
} catch (InterruptedException e) {
log.info("interrupted... ");
}
- log.debug("out of waiting curr-time:{} time-elapsed {}", time(timeSource, MILLISECONDS), timeElapsed(timeSource, waitStart, MILLISECONDS));
+ if (log.isDebugEnabled()) {
+ log.debug("out of waiting curr-time:{} time-elapsed {}"
+ , time(timeSource, MILLISECONDS), timeElapsed(timeSource, waitStart, MILLISECONDS));
+ }
// now this thread has woken up because it got timed out after 10 seconds or it is notified after
// the session was returned from another COMPUTING operation
if (this.sessionWrapper.status == Status.UNUSED || this.sessionWrapper.status == Status.EXECUTING) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/UnsupportedSuggester.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/UnsupportedSuggester.java
index 9d44ae41128..ab5c28b07b6 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/UnsupportedSuggester.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/UnsupportedSuggester.java
@@ -48,7 +48,7 @@ public class UnsupportedSuggester extends Suggester {
@Override
SolrRequest init() {
- log.warn("Unsupported suggester for action " + action + " with hints " + hints + " - no suggestion available");
+ log.warn("Unsupported suggester for action {} with hings {} - no suggestion available", action, hints);
return null;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index fbcd0407ec7..73dc6c170d6 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -343,12 +343,16 @@ public abstract class BaseCloudSolrClient extends SolrClient {
* @throws InterruptedException if the wait is interrupted
*/
public void connect(long duration, TimeUnit timeUnit) throws TimeoutException, InterruptedException {
- log.info("Waiting for {} {} for cluster at {} to be ready", duration, timeUnit, getClusterStateProvider());
+ if (log.isInfoEnabled()) {
+ log.info("Waiting for {} {} for cluster at {} to be ready", duration, timeUnit, getClusterStateProvider());
+ }
long timeout = System.nanoTime() + timeUnit.toNanos(duration);
while (System.nanoTime() < timeout) {
try {
connect();
- log.info("Cluster at {} ready", getClusterStateProvider());
+ if (log.isInfoEnabled()) {
+ log.info("Cluster at {} ready", getClusterStateProvider());
+ }
return;
}
catch (RuntimeException e) {
@@ -943,8 +947,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
rootCause instanceof SocketException ||
wasCommError(rootCause));
- log.error("Request to collection {} failed due to (" + errorCode + ") {}, retry={} commError={} errorCode={} ",
- inputCollections, rootCause.toString(), retryCount, wasCommError, errorCode);
+ log.error("Request to collection {} failed due to ({}) {}, retry={} commError={} errorCode={} ",
+ inputCollections, errorCode, rootCause, retryCount, wasCommError, errorCode);
if (wasCommError
|| (exc instanceof RouteException && (errorCode == 503)) // 404 because the core does not exist 503 service unavailable
@@ -1014,7 +1018,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// if the state was stale, then we retry the request once with new state pulled from Zk
if (stateWasStale) {
- log.warn("Re-trying request to collection(s) "+inputCollections+" after stale state error from server.");
+ log.warn("Re-trying request to collection(s) {} after stale state error from server.", inputCollections);
resp = requestWithRetryOnStaleState(request, retryCount+1, inputCollections);
} else {
if (exc instanceof SolrException || exc instanceof SolrServerException || exc instanceof IOException) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
index a50867c5501..03fb2aabc81 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
@@ -87,8 +87,8 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
ClusterState cs = fetchClusterState(client, collection, null);
return cs.getCollectionRef(collection);
} catch (SolrServerException | IOException e) {
- log.warn("Attempt to fetch cluster state from " +
- Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e);
+ log.warn("Attempt to fetch cluster state from {} failed."
+ , Utils.getBaseUrlForNodeName(nodeName, urlScheme), e);
} catch (RemoteSolrException e) {
if ("NOT_FOUND".equals(e.getMetadata("CLUSTERSTATUS"))) {
return null;
@@ -226,8 +226,9 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
} catch (SolrServerException | RemoteSolrException | IOException e) {
// Situation where we're hitting an older Solr which doesn't have LISTALIASES
if (e instanceof RemoteSolrException && ((RemoteSolrException)e).code()==400) {
- log.warn("LISTALIASES not found, possibly using older Solr server. Aliases won't work"
- + " unless you re-create the CloudSolrClient using zkHost(s) or upgrade Solr server", e);
+ log.warn("LISTALIASES not found, possibly using older Solr server. Aliases won't work {}"
+ ,"unless you re-create the CloudSolrClient using zkHost(s) or upgrade Solr server"
+ , e);
this.aliases = Collections.emptyMap();
this.aliasProperties = Collections.emptyMap();
this.aliasesTimestamp = System.nanoTime();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
index 36aafa05daa..ea0f773edc8 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
@@ -269,7 +269,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
} catch (Exception exc) {
// don't want to fail to report error if parsing the response fails
- log.warn("Failed to parse error response from " + basePath + " due to: " + exc);
+ log.warn("Failed to parse error response from {} due to: ", basePath, exc);
} finally {
solrExc = new BaseHttpSolrClient.RemoteSolrException(basePath , statusCode, msg.toString(), null);
if (metadata != null) {
@@ -500,8 +500,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
if (queueSize > 0 && runners.isEmpty()) {
// TODO: can this still happen?
- log.warn("No more runners, but queue still has " +
- queueSize + " adding more runners to process remaining requests on queue");
+ log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
+ , queueSize);
addRunner();
}
@@ -538,16 +538,16 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
int lastQueueSize = -1;
while (!queue.isEmpty()) {
if (scheduler.isTerminated()) {
- log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. "
- + "Queue size: {}, Runners: {}. Current thread Interrupted? {}", scheduler, queue.size(), runners.size(), threadInterrupted);
+ log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}"
+ , scheduler, queue.size(), runners.size(), threadInterrupted);
break;
}
synchronized (runners) {
int queueSize = queue.size();
if (queueSize > 0 && runners.isEmpty()) {
- log.warn("No more runners, but queue still has " +
- queueSize + " adding more runners to process remaining requests on queue");
+ log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
+ , queueSize);
addRunner();
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index 22c79700202..c95cbd7991b 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -387,7 +387,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
} catch (Exception exc) {
// don't want to fail to report error if parsing the response fails
- log.warn("Failed to parse error response from " + client.getBaseURL() + " due to: " + exc);
+ log.warn("Failed to parse error response from {} due to: ", client.getBaseURL(), exc);
} finally {
solrExc = new BaseHttpSolrClient.RemoteSolrException(client.getBaseURL(), statusCode, msg.toString(), null);
if (metadata != null) {
@@ -637,8 +637,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
if (queueSize > 0 && runners.isEmpty()) {
// TODO: can this still happen?
- log.warn("No more runners, but queue still has " +
- queueSize + " adding more runners to process remaining requests on queue");
+ log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
+ , queueSize);
addRunner();
}
@@ -676,16 +676,16 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
while (!queue.isEmpty()) {
if (log.isDebugEnabled()) emptyQueueLoops.incrementAndGet();
if (scheduler.isTerminated()) {
- log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. "
- + "Queue size: {}, Runners: {}. Current thread Interrupted? {}", scheduler, queue.size(), runners.size(), threadInterrupted);
+ log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}"
+ , scheduler, queue.size(), runners.size(), threadInterrupted);
break;
}
synchronized (runners) {
int queueSize = queue.size();
if (queueSize > 0 && runners.isEmpty()) {
- log.warn("No more runners, but queue still has " +
- queueSize + " adding more runners to process remaining requests on queue");
+ log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
+ , queueSize);
addRunner();
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientUtil.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientUtil.java
index 12c491939aa..c685a0d3302 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClientUtil.java
@@ -156,7 +156,7 @@ public class HttpClientUtil {
// Configure the SocketFactoryRegistryProvider if user has specified the provider type.
String socketFactoryRegistryProviderClassName = System.getProperty(SYS_PROP_SOCKET_FACTORY_REGISTRY_PROVIDER);
if (socketFactoryRegistryProviderClassName != null) {
- log.debug("Using " + socketFactoryRegistryProviderClassName);
+ log.debug("Using {}", socketFactoryRegistryProviderClassName);
try {
socketFactoryRegistryProvider = (SocketFactoryRegistryProvider)Class.forName(socketFactoryRegistryProviderClassName).getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException | InvocationTargetException | NoSuchMethodException e) {
@@ -167,7 +167,7 @@ public class HttpClientUtil {
// Configure the HttpClientBuilder if user has specified the factory type.
String factoryClassName = System.getProperty(SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);
if (factoryClassName != null) {
- log.debug ("Using " + factoryClassName);
+ log.debug ("Using {}", factoryClassName);
try {
HttpClientBuilderFactory factory = (HttpClientBuilderFactory)Class.forName(factoryClassName).getConstructor().newInstance();
httpClientBuilder = factory.getHttpClientBuilder(Optional.of(SolrHttpClientBuilder.create()));
@@ -254,7 +254,7 @@ public class HttpClientUtil {
} else {
sslConnectionSocketFactory = new SSLConnectionSocketFactory(SSLContexts.createSystemDefault(),
NoopHostnameVerifier.INSTANCE);
- log.debug(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME + "is false, hostname checks disabled.");
+ log.debug("{} is false, hostname checks disabled.", HttpClientUtil.SYS_PROP_CHECK_PEER_NAME);
}
builder.register("https", sslConnectionSocketFactory);
@@ -289,7 +289,7 @@ public class HttpClientUtil {
public static CloseableHttpClient createClient(final SolrParams params, PoolingHttpClientConnectionManager cm, boolean sharedConnectionManager, HttpRequestExecutor httpRequestExecutor) {
final ModifiableSolrParams config = new ModifiableSolrParams(params);
if (log.isDebugEnabled()) {
- log.debug("Creating new http client, config:" + config);
+ log.debug("Creating new http client, config: {}", config);
}
cm.setMaxTotal(params.getInt(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000));
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java
index 51977d79402..a6b12177519 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Krb5HttpClientBuilder.java
@@ -134,7 +134,7 @@ public class Krb5HttpClientBuilder implements HttpClientBuilderFactory {
String configValue = System.getProperty(LOGIN_CONFIG_PROP);
if (configValue != null) {
- log.info("Setting up SPNego auth with config: " + configValue);
+ log.info("Setting up SPNego auth with config: {}", configValue);
final String useSubjectCredsProp = "javax.security.auth.useSubjectCredsOnly";
String useSubjectCredsVal = System.getProperty(useSubjectCredsProp);
@@ -145,8 +145,8 @@ public class Krb5HttpClientBuilder implements HttpClientBuilderFactory {
} else if (!useSubjectCredsVal.toLowerCase(Locale.ROOT).equals("false")) {
// Don't overwrite the prop value if it's already been written to something else,
// but log because it is likely the Credentials won't be loaded correctly.
- log.warn("System Property: " + useSubjectCredsProp + " set to: " + useSubjectCredsVal
- + " not false. SPNego authentication may not be successful.");
+ log.warn("System Property: {} set to: {} not false. SPNego authentication may not be successful."
+ , useSubjectCredsProp, useSubjectCredsVal);
}
javax.security.auth.login.Configuration.setConfiguration(jaasConfig);
@@ -224,11 +224,13 @@ public class Krb5HttpClientBuilder implements HttpClientBuilderFactory {
public AppConfigurationEntry[] getAppConfigurationEntry(String appName) {
if (baseConfig == null) return null;
- log.debug("Login prop: "+System.getProperty(LOGIN_CONFIG_PROP));
+ if (log.isDebugEnabled()) {
+ log.debug("Login prop: {}", System.getProperty(LOGIN_CONFIG_PROP));
+ }
String clientAppName = System.getProperty("solr.kerberos.jaas.appname", "Client");
if (initiateAppNames.contains(appName)) {
- log.debug("Using AppConfigurationEntry for appName '"+clientAppName+"' instead of: " + appName);
+ log.debug("Using AppConfigurationEntry for appName '{}' instead of: '{}'", clientAppName, appName);
return baseConfig.getAppConfigurationEntry(clientAppName);
}
return baseConfig.getAppConfigurationEntry(appName);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
index 03bb91aec6f..4f63525b4d5 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java
@@ -360,7 +360,9 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
}
if (hasIOExceptionCause) {
- log.info("Error on getting remote info, trying again: {}", e.getMessage());
+ if (log.isInfoEnabled()) {
+ log.info("Error on getting remote info, trying again: {}", e.getMessage());
+ }
Thread.sleep(500);
} else {
throw e;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpRequestRetryHandler.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpRequestRetryHandler.java
index 51b567a3579..c628bb6fdd1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpRequestRetryHandler.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrHttpRequestRetryHandler.java
@@ -111,7 +111,9 @@ public class SolrHttpRequestRetryHandler implements HttpRequestRetryHandler {
}
if (!isRetriable(exception)) {
- log.debug("Do not retry, non retriable class {}", exception.getClass().getName());
+ if (log.isDebugEnabled()) {
+ log.debug("Do not retry, non retriable class {}", exception.getClass().getName());
+ }
return false;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
index 16c66b21c98..a1bf842b1ae 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
@@ -70,7 +70,7 @@ public class XMLResponseParser extends ResponseParser
catch( IllegalArgumentException ex ) {
// Other implementations will likely throw this exception since "reuse-instance"
// isimplementation specific.
- log.debug( "Unable to set the 'reuse-instance' property for the input factory: "+factory );
+ log.debug( "Unable to set the 'reuse-instance' property for the input factory: {}", factory );
}
factory.setXMLReporter(xmllog);
}
@@ -175,7 +175,9 @@ public class XMLResponseParser extends ResponseParser
return new Date(Instant.parse(txt).toEpochMilli());
}
catch( Exception ex ) {
- log.info(ex.getMessage(),ex);
+ if (log.isInfoEnabled()) {
+ log.info("{}", ex.getMessage(), ex);
+ }
}
return null;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
index cc4b0453111..407349613e3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
@@ -238,7 +238,7 @@ public class ZkClientClusterStateProvider implements ClusterStateProvider {
/* Log the constructed connection string and then initialize. */
final String zkHostString = zkBuilder.toString();
- log.debug("Final constructed zkHost string: " + zkHostString);
+ log.debug("Final constructed zkHost string: {}", zkHostString);
return zkHostString;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
index a813f30f27f..7151e5ddd8c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java
@@ -91,7 +91,7 @@ public class SolrClientCache implements Serializable {
try {
entry.getValue().close();
} catch (IOException e) {
- log.error("Error closing SolrClient for " + entry.getKey(), e);
+ log.error("Error closing SolrClient for {}", entry.getKey(), e);
}
}
solrClients.clear();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
index ce6d0a91860..0257be9e3d3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
@@ -365,14 +365,14 @@ public class DaemonStream extends TupleStream implements Expressible {
}
} catch (IOException e) {
exception = e;
- log.error("Error in DaemonStream:" + id, e);
+ log.error("Error in DaemonStream: {}", id, e);
++errors;
if (errors > 100) {
- log.error("Too many consecutive errors. Stopping DaemonStream:" + id);
+ log.error("Too many consecutive errors. Stopping DaemonStream: {}", id);
break OUTER;
}
} catch (Throwable t) {
- log.error("Fatal Error in DaemonStream:" + id, t);
+ log.error("Fatal Error in DaemonStream: {}", id, t);
//For anything other then IOException break out of the loop and shutdown the thread.
break OUTER;
} finally {
@@ -381,7 +381,7 @@ public class DaemonStream extends TupleStream implements Expressible {
} catch (IOException e1) {
if (exception == null) {
exception = e1;
- log.error("Error in DaemonStream:" + id, e1);
+ log.error("Error in DaemonStream: {}", id, e1);
break OUTER;
}
}
@@ -393,7 +393,7 @@ public class DaemonStream extends TupleStream implements Expressible {
try {
Thread.sleep(sleepMillis);
} catch (InterruptedException e) {
- log.error("Error in DaemonStream:" + id, e);
+ log.error("Error in DaemonStream:{}", id, e);
break OUTER;
}
}
@@ -406,7 +406,7 @@ public class DaemonStream extends TupleStream implements Expressible {
try {
queue.put(tuple);
} catch (InterruptedException e) {
- log.error("Error in DaemonStream:"+id, e);
+ log.error("Error in DaemonStream:{}", id, e);
}
}
setStopTime(new Date().getTime());
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ExecutorStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ExecutorStream.java
index aae9c659b80..10b6873856f 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ExecutorStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ExecutorStream.java
@@ -214,7 +214,7 @@ public class ExecutorStream extends TupleStream implements Expressible {
}
}
} catch (Exception e) {
- log.error("Executor Error: id="+id+" expr_s="+expr, e);
+ log.error("Executor Error: id={} expr_s={}", id, expr, e);
} finally {
try {
stream.close();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/RequestReplicaListTransformerGenerator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/RequestReplicaListTransformerGenerator.java
index 12ce4cf10f3..4a1fc30e9bc 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/RequestReplicaListTransformerGenerator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/RequestReplicaListTransformerGenerator.java
@@ -139,7 +139,7 @@ public class RequestReplicaListTransformerGenerator {
if (choices.size() > 1) {
if (log.isDebugEnabled()) {
log.debug("Applying the following sorting preferences to replicas: {}",
- Arrays.toString(replicaComp.getPreferenceRules().toArray()));
+ Arrays.toString(replicaComp.getPreferenceRules().toArray())); // logOK
}
// First, sort according to comparator rules.
@@ -180,8 +180,7 @@ public class RequestReplicaListTransformerGenerator {
}
if (log.isDebugEnabled()) {
- log.debug("Applied sorting preferences to replica list: {}",
- Arrays.toString(choices.toArray()));
+ log.debug("Applied sorting preferences to replica list: {}", Arrays.toString(choices.toArray())); // logOK
}
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
index 1752377daec..cc0e5089c5b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
@@ -111,7 +111,9 @@ public class ConnectionManager implements Watcher {
if (event.getState() == AuthFailed || event.getState() == Disconnected || event.getState() == Expired) {
log.warn("Watcher {} name: {} got event {} path: {} type: {}", this, name, event, event.getPath(), event.getType());
} else {
- log.debug("Watcher {} name: {} got event {} path: {} type: {}", this, name, event, event.getPath(), event.getType());
+ if (log.isDebugEnabled()) {
+ log.debug("Watcher {} name: {} got event {} path: {} type: {}", this, name, event, event.getPath(), event.getType());
+ }
}
if (isClosed()) {
@@ -187,7 +189,7 @@ public class ConnectionManager implements Watcher {
}
} while (!isClosed());
- log.info("zkClient Connected:" + connected);
+ log.info("zkClient Connected: {}", connected);
} else if (state == KeeperState.Disconnected) {
log.warn("zkClient has disconnected");
disconnected();
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/NodesSysPropsCacher.java b/solr/solrj/src/java/org/apache/solr/common/cloud/NodesSysPropsCacher.java
index 186a32cbf62..8d185a2e5f7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/NodesSysPropsCacher.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/NodesSysPropsCacher.java
@@ -154,10 +154,10 @@ public class NodesSysPropsCacher implements SolrCloseable {
Thread.sleep(backOffTime);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
- log.info("Exception on caching node:{} system.properties:{}, retry {}/{}", node, tags, i+1, NUM_RETRY, e);
+ log.info("Exception on caching node:{} system.properties:{}, retry {}/{}", node, tags, i+1, NUM_RETRY, e); // logOk
break;
}
- log.info("Exception on caching node:{} system.properties:{}, retry {}/{}", node, tags, i+1, NUM_RETRY, e);
+ log.info("Exception on caching node:{} system.properties:{}, retry {}/{}", node, tags, i+1, NUM_RETRY, e); // logOk
}
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index 03170c3b0ba..7af119ac469 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -223,7 +223,7 @@ public class SolrZkClient implements Closeable {
String zkCredentialsProviderClassName = System.getProperty(ZK_CRED_PROVIDER_CLASS_NAME_VM_PARAM_NAME);
if (!StringUtils.isEmpty(zkCredentialsProviderClassName)) {
try {
- log.info("Using ZkCredentialsProvider: " + zkCredentialsProviderClassName);
+ log.info("Using ZkCredentialsProvider: {}", zkCredentialsProviderClassName);
return (ZkCredentialsProvider)Class.forName(zkCredentialsProviderClassName).getConstructor().newInstance();
} catch (Throwable t) {
// just ignore - go default
@@ -239,7 +239,7 @@ public class SolrZkClient implements Closeable {
String zkACLProviderClassName = System.getProperty(ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME);
if (!StringUtils.isEmpty(zkACLProviderClassName)) {
try {
- log.info("Using ZkACLProvider: " + zkACLProviderClassName);
+ log.info("Using ZkACLProvider: {}", zkACLProviderClassName);
return (ZkACLProvider)Class.forName(zkACLProviderClassName).getConstructor().newInstance();
} catch (Throwable t) {
// just ignore - go default
@@ -579,7 +579,9 @@ public class SolrZkClient implements Closeable {
*/
public Stat setData(String path, File file, boolean retryOnConnLoss) throws IOException,
KeeperException, InterruptedException {
- log.debug("Write to ZooKeeper: {} to {}", file.getAbsolutePath(), path);
+ if (log.isDebugEnabled()) {
+ log.debug("Write to ZooKeeper: {} to {}", file.getAbsolutePath(), path);
+ }
byte[] data = FileUtils.readFileToByteArray(file);
return setData(path, data, retryOnConnLoss);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
index bf4a1eddea9..aa6404bf0a7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
@@ -139,8 +139,7 @@ public class ZkConfigManager {
List<String> children = zkClient.getChildren(fromZkPath + "/" + file, null, true);
if (children.size() == 0) {
final String toZkFilePath = toZkPath + "/" + file;
- log.info("Copying zk node {} to {}",
- fromZkPath + "/" + file, toZkFilePath);
+ log.info("Copying zk node {}/{} to {}", fromZkPath, file, toZkFilePath);
byte[] data = zkClient.getData(fromZkPath + "/" + file, null, null, true);
zkClient.makePath(toZkFilePath, data, true);
if (copiedToZkPaths != null) copiedToZkPaths.add(toZkFilePath);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
index b7e5072bd5d..915547e36b2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
@@ -328,7 +328,7 @@ public class ZkMaintenanceUtils {
private static int copyDataDown(SolrZkClient zkClient, String zkPath, File file) throws IOException, KeeperException, InterruptedException {
byte[] data = zkClient.getData(zkPath, null, null, true);
if (data != null && data.length > 1) { // There are apparently basically empty ZNodes.
- log.info("Writing file {}", file.toString());
+ log.info("Writing file {}", file);
Files.write(file.toPath(), data);
return data.length;
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 3d9739d51ac..93094aac872 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -461,7 +461,9 @@ public class ZkStateReader implements SolrCloseable {
DocCollection collection = clusterState.getCollectionOrNull(coll);
if (collection == null) return null;
if (collection.getZNodeVersion() < version) {
- log.debug("Server older than client {}<{}", collection.getZNodeVersion(), version);
+ if (log.isDebugEnabled()) {
+ log.debug("Server older than client {}<{}", collection.getZNodeVersion(), version);
+ }
DocCollection nu = getCollectionLive(this, coll);
if (nu == null) return -1;
if (nu.getZNodeVersion() > collection.getZNodeVersion()) {
@@ -478,7 +480,9 @@ public class ZkStateReader implements SolrCloseable {
return null;
}
- log.debug("Wrong version from client [{}]!=[{}]", version, collection.getZNodeVersion());
+ if (log.isDebugEnabled()) {
+ log.debug("Wrong version from client [{}]!=[{}]", version, collection.getZNodeVersion());
+ }
return collection.getZNodeVersion();
}
@@ -586,12 +590,14 @@ public class ZkStateReader implements SolrCloseable {
this.clusterState = new ClusterState(liveNodes, result, legacyClusterStateVersion);
- log.debug("clusterStateSet: legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]",
- legacyCollectionStates.keySet().size(),
- collectionWatches.keySet().size(),
- watchedCollectionStates.keySet().size(),
- lazyCollectionStates.keySet().size(),
- clusterState.getCollectionStates().size());
+ if (log.isDebugEnabled()) {
+ log.debug("clusterStateSet: legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]",
+ legacyCollectionStates.keySet().size(),
+ collectionWatches.keySet().size(),
+ watchedCollectionStates.keySet().size(),
+ lazyCollectionStates.keySet().size(),
+ clusterState.getCollectionStates().size());
+ }
if (log.isTraceEnabled()) {
log.trace("clusterStateSet: legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]",
@@ -836,7 +842,9 @@ public class ZkStateReader implements SolrCloseable {
}
}
if (oldLiveNodes.size() != newLiveNodes.size()) {
- log.info("Updated live nodes from ZooKeeper... ({}) -> ({})", oldLiveNodes.size(), newLiveNodes.size());
+ if (log.isInfoEnabled()) {
+ log.info("Updated live nodes from ZooKeeper... ({}) -> ({})", oldLiveNodes.size(), newLiveNodes.size());
+ }
}
if (log.isDebugEnabled()) {
log.debug("Updated live nodes from ZooKeeper... {} -> {}", oldLiveNodes, newLiveNodes);
@@ -1305,8 +1313,10 @@ public class ZkStateReader implements SolrCloseable {
}
Set<String> liveNodes = ZkStateReader.this.liveNodes;
- log.info("A cluster state change: [{}] for collection [{}] has occurred - updating... (live nodes size: [{}])",
- event, coll, liveNodes.size());
+ if (log.isInfoEnabled()) {
+ log.info("A cluster state change: [{}] for collection [{}] has occurred - updating... (live nodes size: [{}])",
+ event, coll, liveNodes.size());
+ }
refreshAndWatch();
@@ -1513,7 +1523,9 @@ public class ZkStateReader implements SolrCloseable {
if (EventType.None.equals(event.getType())) {
return;
}
- log.debug("A live node change: [{}], has occurred - updating... (live nodes size: [{}])", event, liveNodes.size());
+ if (log.isDebugEnabled()) {
+ log.debug("A live node change: [{}], has occurred - updating... (live nodes size: [{}])", event, liveNodes.size());
+ }
refreshAndWatch();
}
@@ -1923,7 +1935,9 @@ public class ZkStateReader implements SolrCloseable {
DocCollection oldState = watchedCollectionStates.get(coll);
if (oldState == null) {
if (watchedCollectionStates.putIfAbsent(coll, newState) == null) {
- log.debug("Add data for [{}] ver [{}]", coll, newState.getZNodeVersion());
+ if (log.isDebugEnabled()) {
+ log.debug("Add data for [{}] ver [{}]", coll, newState.getZNodeVersion());
+ }
updated = true;
break;
}
@@ -1935,7 +1949,9 @@ public class ZkStateReader implements SolrCloseable {
break;
}
if (watchedCollectionStates.replace(coll, oldState, newState)) {
- log.debug("Updating data for [{}] from [{}] to [{}]", coll, oldState.getZNodeVersion(), newState.getZNodeVersion());
+ if (log.isDebugEnabled()) {
+ log.debug("Updating data for [{}] from [{}] to [{}]", coll, oldState.getZNodeVersion(), newState.getZNodeVersion());
+ }
updated = true;
break;
}
@@ -2123,7 +2139,7 @@ public class ZkStateReader implements SolrCloseable {
setIfNewer(Aliases.fromJSON(modAliasesJson, stat.getVersion()));
return;
} catch (KeeperException.BadVersionException e) {
- log.debug(e.toString(), e);
+ log.debug("{}", e.toString(), e); // logOk
log.warn("Couldn't save aliases due to race with another modification; will update and retry until timeout");
// considered a backoff here, but we really do want to compete strongly since the normal case is
// that we will do one update and succeed. This is left as a hot loop for limited tries intentionally.
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java
index a21074159c5..3f137712610 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/RetryUtil.java
@@ -48,7 +48,9 @@ public class RetryUtil {
cmd.execute();
} catch (Throwable t) {
if (isInstanceOf(classes, t) && System.nanoTime() < timeout) {
- log.info("Retry due to Throwable, " + t.getClass().getName() + " " + t.getMessage());
+ if (log.isInfoEnabled()) {
+ log.info("Retry due to Throwable, {} {}", t.getClass().getName(), t.getMessage());
+ }
Thread.sleep(intervalms);
continue;
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
index f9dd7c74c2e..a202652da74 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
@@ -92,7 +92,7 @@ public class StrUtils {
/***
if (SolrCore.log.isLoggable(Level.FINEST)) {
- SolrCore.log.trace("splitCommand=" + lst);
+ SolrCore.log.trace("splitCommand={}", lst);
}
***/
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java b/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
index 2e5cd2aeb9b..03dfdfd62c0 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
@@ -188,12 +188,12 @@ public abstract class TimeSource {
String[] parts = t.split(":");
double mul = 1.0;
if (parts.length != 2) {
- log.warn("Invalid simTime specification, assuming multiplier==1.0: '" + type + "'");
+ log.warn("Invalid simTime specification, assuming multiplier==1.0: '{}'.", type);
} else {
try {
mul = Double.parseDouble(parts[1]);
} catch (Exception e) {
- log.warn("Invalid simTime specification, assuming multiplier==1.0: '" + type + "'");
+ log.warn("Invalid simTime specification, assuming multiplier==1.0: '{}'.", type);
}
}
return new SimTimeSource(mul);
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
index fd5eafaadb8..79e6965c5a7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
@@ -769,13 +769,15 @@ public class Utils {
try {
rsp = client.execute(httpGet);
} catch (IOException e) {
- log.error("Error in request to url : " + url, e);
+ log.error("Error in request to url : {}", url, e);
throw new SolrException(SolrException.ErrorCode.UNKNOWN, "error sending request");
}
int statusCode = rsp.getStatusLine().getStatusCode();
if (statusCode != 200) {
try {
- log.error("Failed a request to: {}, status: {}, body: {}", url, rsp.getStatusLine(), EntityUtils.toString(rsp.getEntity(), StandardCharsets.UTF_8));
+ if (log.isErrorEnabled()) {
+ log.error("Failed a request to: {}, status: {}, body: {}", url, rsp.getStatusLine(), EntityUtils.toString(rsp.getEntity(), StandardCharsets.UTF_8)); // logOk
+ }
} catch (IOException e) {
log.error("could not print error", e);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/XMLErrorLogger.java b/solr/solrj/src/java/org/apache/solr/common/util/XMLErrorLogger.java
index 2bcfbd46135..cee109a90e2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/XMLErrorLogger.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/XMLErrorLogger.java
@@ -38,7 +38,7 @@ public final class XMLErrorLogger implements ErrorHandler,ErrorListener,XMLRepor
@Override
public void warning(SAXParseException e) {
- log.warn("XML parse warning in \""+e.getSystemId()+"\", line "+e.getLineNumber()+", column "+e.getColumnNumber()+": "+e.getMessage());
+ log.warn("XML parse warning in '{}', line {}, column {}: {}", e.getSystemId(), e.getLineNumber(), e.getColumnNumber(), e.getMessage());
}
@Override
@@ -77,7 +77,7 @@ public final class XMLErrorLogger implements ErrorHandler,ErrorListener,XMLRepor
sb.append(" in \"").append(loc.getSystemId()).append("\", line ")
.append(loc.getLineNumber()).append(", column ").append(loc.getColumnNumber());
}
- log.warn(sb.append(": ").append(message).toString());
+ log.warn("{}", sb.append(": ").append(message));
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java
index eb1dbc53c12..f54fc0b14e0 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java
@@ -52,7 +52,7 @@ public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase
threads[i] = new DocThread( "T"+i+":" );
threads[i].setName("DocThread-" + i);
threads[i].start();
- log.info("Started thread: " + i);
+ log.info("Started thread: {}", i);
}
for (int i=0; i<threadCount; i++) {
threads[i].join();
@@ -98,7 +98,9 @@ public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase
docs = new ArrayList<>();
}
if (i > 0 && i % 5000 == 0) {
- log.info(getName() + " - Committing " + i);
+ if (log.isInfoEnabled()) {
+ log.info("{} - Committing {}", getName(), i);
+ }
resp = client.commit();
assertEquals(0, resp.getStatus());
}
@@ -117,7 +119,9 @@ public abstract class LargeVolumeTestBase extends EmbeddedSolrServerTestBase
assertEquals(0, resp.getStatus());
} catch (Exception e) {
// a commit/optimize can fail with a too many warming searchers exception
- log.info("Caught benign exception during commit: " + e.getMessage());
+ if (log.isInfoEnabled()) {
+ log.info("Caught benign exception during commit: {}", e.getMessage());
+ }
}
if (!(client instanceof EmbeddedSolrServer)) {
client.close();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
index a39b33e60ab..e54220399d3 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
@@ -74,7 +74,9 @@ public abstract class MergeIndexesExampleTestBase extends SolrTestCaseJ4 {
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
setupCoreContainer();
- log.info("CORES=" + cores + " : " + cores.getLoadedCoreNames());
+ if (log.isInfoEnabled()) {
+ log.info("CORES={} : {}", cores, cores.getLoadedCoreNames());
+ }
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
index 5119664dc59..d823ad88109 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
@@ -143,7 +143,9 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
rsp = getSolrClient().query(new SolrQuery("*:*").setRows(20));
}
- log.info("time taken to execute {} queries is {} ms",count, timer.getTime());
+ if (log.isInfoEnabled()) {
+ log.info("time taken to execute {} queries is {} ms", count, timer.getTime());
+ }
}
@@ -550,7 +552,9 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
assertTrue("Unexpected exception message: " + concurrentClient.lastError.getMessage(),
concurrentClient.lastError.getMessage().contains("Remote error message: Document contains multiple values for uniqueKey"));
} else {
- log.info("Ignoring update test for client:" + client.getClass().getName());
+ if (log.isInfoEnabled()) {
+ log.info("Ignoring update test for client: {}", client.getClass().getName());
+ }
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java
index 807d9ac0d4b..065a35299a7 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java
@@ -99,7 +99,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
sb.append("\n\t").append(entry.getValue()).append(") ").append(entry.getKey());
}
- log.error(sb.toString());
+ log.error("{}", sb);
}
@Test
@@ -251,11 +251,11 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
} catch (IOException e) {
// a real HTTP client probably wouldn't try to read past the end and would thus
// not get an exception until the *next* http request.
- log.error("CAUGHT IOException, but already read " + sb.length() + " : " + getChain(e));
+ log.error("CAUGHT IOException, but already read {} : {}", sb.length(), getChain(e));
}
if (n <= 0) break;
sb.append(new String(buf, 0, n, StandardCharsets.UTF_8));
- log.info("BUFFER=" + sb.toString());
+ log.info("BUFFER={}", sb);
break; // for now, assume we got whole response in one read... otherwise we could block when trying to read again
}
return sb.toString();
@@ -286,7 +286,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
try {
code = conn.getResponseCode();
} catch (Throwable th) {
- log.error("ERROR DURING conn.getResponseCode():",th);
+ log.error("ERROR DURING conn.getResponseCode():",th); //logOk
}
/***
@@ -299,7 +299,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
*/
- log.info("CODE=" + code);
+ log.info("CODE= {}", code);
InputStream is;
if (code == 200) {
is = conn.getInputStream();
@@ -313,7 +313,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
}
String rbody = IOUtils.toString(is, StandardCharsets.UTF_8);
- log.info("RESPONSE BODY:" + rbody);
+ log.info("RESPONSE BODY:{}", rbody);
}
@Test
@@ -354,7 +354,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
out.flush();
String rbody = getResponse(in); // This will throw a connection reset exception if you try to read past the end of the HTTP response
- log.info("RESPONSE BODY:" + rbody);
+ log.info("RESPONSE BODY: {}", rbody);
assertTrue(rbody.contains("unknown_field"));
/***
@@ -366,7 +366,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
out.flush();
rbody = getResponse(in);
- log.info("RESPONSE BODY:" + rbody);
+ log.info("RESPONSE BODY: {}", rbody);
assertTrue(rbody.contains("unknown_field"));
***/
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
index 9c47ecfb515..0b3c31e16ab 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
@@ -2226,7 +2226,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
Suggester suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
.hint(Hint.TARGET_NODE, "127.0.0.1:51147_solr");
SolrRequest op = suggester.getSuggestion();
- log.info("" + op);
+ log.info("{}", op);
assertNotNull("operation expected ", op);
}
@@ -2686,7 +2686,9 @@ public class TestPolicy extends SolrTestCaseJ4 {
CollectionAdminRequest.MoveReplica op = (CollectionAdminRequest.MoveReplica) suggester.getSuggestion();
if (op == null) break;
count++;
- log.info("OP:{}", op.getParams());
+ if (log.isInfoEnabled()) {
+ log.info("OP:{}", op.getParams());
+ }
suggester = createSuggester(cloudManager, jsonObj, suggester);
}
@@ -2702,7 +2704,9 @@ public class TestPolicy extends SolrTestCaseJ4 {
CollectionAdminRequest.MoveReplica op = (CollectionAdminRequest.MoveReplica) suggester.getSuggestion();
if (op == null) break;
count++;
- log.info("OP:{}", op.getParams());
+ if (log.isInfoEnabled()) {
+ log.info("OP:{}", op.getParams());
+ }
suggester = createSuggester(cloudManager, jsonObj, suggester);
}
@@ -2718,7 +2722,9 @@ public class TestPolicy extends SolrTestCaseJ4 {
CollectionAdminRequest.MoveReplica op = (CollectionAdminRequest.MoveReplica) suggester.getSuggestion();
if (op == null) break;
count++;
- log.info("OP:{}", op.getParams());
+ if (log.isInfoEnabled()) {
+ log.info("OP:{}", op.getParams());
+ }
suggester = createSuggester(cloudManager, jsonObj, suggester);
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
index 446022382cc..ec777364481 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
@@ -576,7 +576,7 @@ public class BasicHttpSolrClientTest extends SolrJettyTestBase {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException,
IOException {
- log.info("Intercepted params: "+context);
+ log.info("Intercepted params: {}", context);
HttpRequestWrapper wrapper = (HttpRequestWrapper) request;
URIBuilder uribuilder = new URIBuilder(wrapper.getURI());
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
index 23acbf60548..c408b2eefa6 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
@@ -376,7 +376,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.set(CommonParams.Q, "*:*");
solrParams.set(ShardParams._ROUTE_, sameShardRoutes.get(random().nextInt(sameShardRoutes.size())));
- log.info("output: {}", getRandomClient().query("routing_collection", solrParams));
+ if (log.isInfoEnabled()) {
+ log.info("output: {}", getRandomClient().query("routing_collection", solrParams));
+ }
}
// Request counts increase from expected nodes should aggregate to 1000, while there should be
@@ -475,7 +477,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
assertNotNull(ShardParams.SHARDS_INFO+" did not return 'shardAddress' parameter", shardAddress);
shardAddresses.add(shardAddress);
}
- log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));
+ if (log.isInfoEnabled()) {
+ log.info("Shards giving the response: {}", Arrays.toString(shardAddresses.toArray())); // logOK
+ }
// Make sure the distributed queries were directed to a single node only
Set<Integer> ports = new HashSet<Integer>();
@@ -613,7 +617,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
for (JettySolrRunner runner : cluster.getJettySolrRunners()) {
Long numRequests = getNumRequests(runner.getBaseUrl().toString(), "foo", "ADMIN", adminPathToMbean.get(adminPath), adminPath, true);
errorsBefore += numRequests;
- log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ if (log.isInfoEnabled()) {
+ log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ }
}
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -630,7 +636,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
for (JettySolrRunner runner : cluster.getJettySolrRunners()) {
Long numRequests = getNumRequests(runner.getBaseUrl().toString(), "foo", "ADMIN", adminPathToMbean.get(adminPath), adminPath, true);
errorsAfter += numRequests;
- log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ if (log.isInfoEnabled()) {
+ log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ }
}
assertEquals(errorsBefore + 1, errorsAfter);
}
@@ -699,10 +707,14 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
final String url = r.getStr(ZkStateReader.BASE_URL_PROP) + "/" + COLLECTION;
try (HttpSolrClient solrClient = getHttpSolrClient(url)) {
- log.info("should work query, result {}", solrClient.query(q));
+ if (log.isInfoEnabled()) {
+ log.info("should work query, result {}", solrClient.query(q));
+ }
//no problem
q.setParam(CloudSolrClient.STATE_VERSION, COLLECTION + ":" + coll.getZNodeVersion());
- log.info("2nd query , result {}", solrClient.query(q));
+ if (log.isInfoEnabled()) {
+ log.info("2nd query , result {}", solrClient.query(q));
+ }
//no error yet good
q.setParam(CloudSolrClient.STATE_VERSION, COLLECTION + ":" + (coll.getZNodeVersion() - 1)); //an older version expect error
@@ -1050,7 +1062,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
shardAddresses.add(shardAddress);
}
assertTrue("No responses", shardAddresses.size() > 0);
- log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));
+ if (log.isInfoEnabled()) {
+ log.info("Shards giving the response: {}", Arrays.toString(shardAddresses.toArray())); // logOK
+ }
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 964d34374e8..e02f501762a 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -364,7 +364,9 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.set(CommonParams.Q, "*:*");
solrParams.set(ShardParams._ROUTE_, sameShardRoutes.get(random().nextInt(sameShardRoutes.size())));
- log.info("output: {}", getRandomClient().query("routing_collection", solrParams));
+ if (log.isInfoEnabled()) {
+ log.info("output: {}", getRandomClient().query("routing_collection", solrParams));
+ }
}
// Request counts increase from expected nodes should aggregate to 1000, while there should be
@@ -463,7 +465,9 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
assertNotNull(ShardParams.SHARDS_INFO+" did not return 'shardAddress' parameter", shardAddress);
shardAddresses.add(shardAddress);
}
- log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));
+ if (log.isInfoEnabled()) {
+ log.info("Shards giving the response: {}", Arrays.toString(shardAddresses.toArray())); // logOK
+ }
// Make sure the distributed queries were directed to a single node only
Set<Integer> ports = new HashSet<Integer>();
@@ -599,7 +603,9 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
for (JettySolrRunner runner : cluster.getJettySolrRunners()) {
Long numRequests = getNumRequests(runner.getBaseUrl().toString(), "foo", "ADMIN", adminPathToMbean.get(adminPath), adminPath, true);
errorsBefore += numRequests;
- log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ if (log.isInfoEnabled()) {
+ log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ }
}
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -616,7 +622,9 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
for (JettySolrRunner runner : cluster.getJettySolrRunners()) {
Long numRequests = getNumRequests(runner.getBaseUrl().toString(), "foo", "ADMIN", adminPathToMbean.get(adminPath), adminPath, true);
errorsAfter += numRequests;
- log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ if (log.isInfoEnabled()) {
+ log.info("Found {} requests to {} on {}", numRequests, adminPath, runner.getBaseUrl());
+ }
}
assertEquals(errorsBefore + 1, errorsAfter);
}
@@ -685,10 +693,14 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
final String url = r.getStr(ZkStateReader.BASE_URL_PROP) + "/" + COLLECTION;
try (HttpSolrClient solrClient = getHttpSolrClient(url)) {
- log.info("should work query, result {}", solrClient.query(q));
+ if (log.isInfoEnabled()) {
+ log.info("should work query, result {}", solrClient.query(q));
+ }
//no problem
q.setParam(CloudSolrClient.STATE_VERSION, COLLECTION + ":" + coll.getZNodeVersion());
- log.info("2nd query , result {}", solrClient.query(q));
+ if (log.isInfoEnabled()) {
+ log.info("2nd query , result {}", solrClient.query(q));
+ }
//no error yet good
q.setParam(CloudSolrClient.STATE_VERSION, COLLECTION + ":" + (coll.getZNodeVersion() - 1)); //an older version expect error
@@ -1022,7 +1034,9 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
shardAddresses.add(shardAddress);
}
assertTrue("No responses", shardAddresses.size() > 0);
- log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));
+ if (log.isInfoEnabled()) {
+ log.info("Shards giving the response: {}", Arrays.toString(shardAddresses.toArray())); // logOk
+ }
}
@Test
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java
index cb6c2092689..a452465fa40 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java
@@ -521,7 +521,9 @@ public class CloudAuthStreamTest extends SolrCloudTestCase {
daemonCheck.setCredentials(user, user);
final List<Tuple> tuples = getTuples(daemonCheck);
assertEquals(1, tuples.size()); // our daemon;
- log.info("Current daemon status: {}", tuples.get(0).fields);
+ if (log.isInfoEnabled()) {
+ log.info("Current daemon status: {}", tuples.get(0).fields);
+ }
assertEquals(daemonId + " should have never had a successful iteration",
Long.valueOf(0L), tuples.get(0).getLong("iterations"));
state = tuples.get(0).get("state");
diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java b/solr/solrj/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java
index 561f0e4bde1..50bac4986d8 100644
--- a/solr/solrj/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/cloud/SolrZkClientTest.java
@@ -69,7 +69,7 @@ public class SolrZkClientTest extends SolrCloudTestCase {
final String AUTH = "user:pass";
Path zkDir = createTempDir();
- log.info("ZooKeeper dataDir:" + zkDir);
+ log.info("ZooKeeper dataDir:{}", zkDir);
zkServer = new ZkTestServer(zkDir);
zkServer.run();