Skip to content

Apache Lucene open-source search software

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

Erick Ericksonc94770c2b9c0
diff --git a/gradle/validation/validate-log-calls.gradle b/gradle/validation/validate-log-calls.gradle
index ecc7c079943..de28fd37bcf 100644
--- a/gradle/validation/validate-log-calls.gradle
+++ b/gradle/validation/validate-log-calls.gradle
@@ -58,9 +58,19 @@ class ValidateLogCallsTask extends DefaultTask {
, "solr/core/src/java/org/apache/solr/api"
, "solr/core/src/java/org/apache/solr/client"
// , "solr/core/src/java/org/apache/solr/cloud"
+// , "solr/core/src/java/org/apache/solr/cloud/api"
+// , "solr/core/src/java/org/apache/solr/cloud/autoscaling"
+// , "solr/core/src/java/org/apache/solr/cloud/cdcr"
+// , "solr/core/src/java/org/apache/solr/cloud/hdfs"
+// , "solr/core/src/java/org/apache/solr/cloud/overseer"
+// , "solr/core/src/java/org/apache/solr/cloud/rule"
, "solr/core/src/java/org/apache/solr/core"
, "solr/core/src/java/org/apache/solr/filestore"
-// , "solr/core/src/java/org/apache/solr/handler"
+// , "solr/core/src/java/org/apache/solr/handler/admin"
+// , "solr/core/src/java/org/apache/solr/handler/component"
+// , "solr/core/src/java/org/apache/solr/handler/export"
+// , "solr/core/src/java/org/apache/solr/handler/loader"
+// , "solr/core/src/java/org/apache/solr/handler/tagger"
, "solr/core/src/java/org/apache/solr/highlight"
, "solr/core/src/java/org/apache/solr/index"
, "solr/core/src/java/org/apache/solr/internal"
@@ -81,7 +91,7 @@ class ValidateLogCallsTask extends DefaultTask {
, "solr/core/src/java/org/apache/solr/spelling"
, "solr/core/src/java/org/apache/solr/store"
, "solr/core/src/java/org/apache/solr/uninverting"
-// , "solr/core/src/java/org/apache/solr/update"
+ , "solr/core/src/java/org/apache/solr/update"
, "solr/core/src/java/org/apache/solr/util"
]
@@ -123,6 +133,13 @@ class ValidateLogCallsTask extends DefaultTask {
if (prevLine.toLowerCase().contains("is" + level + "enabled")) {
return
}
+ // There's a convention to declare a member variable for whether a level is enabled and check that rather than
+ // isDebugEnabled. So check plusses there too.
+ if (prevLine.toLowerCase().replaceAll("\\s+", "").contains("if(" + level + ")")
+ && (checkPlus == false || line.contains("+") == false)) {
+ return
+ }
+
if (level.equals("error") || level.equals("fatal")) {
if (checkPlus == false || hasPlus == false) {
return
diff --git a/help/validateLogCalls.txt b/help/validateLogCalls.txt
index cc8c0fc8c79..d3a424f9ed4 100644
--- a/help/validateLogCalls.txt
+++ b/help/validateLogCalls.txt
@@ -38,7 +38,7 @@ NOTES:
we can use lambdas rather than "if log.is*Enabled". slf4j 2.0
will when released.
-- error and fatal level messages are NOT checked. However, if you want to
+- error and fatal level messages are NOT flagged. However, if you want to
check these levels for including '+', specify '-PcheckPlus=true'. This is more
a style than functional check.
diff --git a/solr/core/src/java/org/apache/solr/update/CdcrTransactionLog.java b/solr/core/src/java/org/apache/solr/update/CdcrTransactionLog.java
index f668540325e..fbf686157d2 100644
--- a/solr/core/src/java/org/apache/solr/update/CdcrTransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/CdcrTransactionLog.java
@@ -102,7 +102,7 @@ public class CdcrTransactionLog extends TransactionLog {
}
}
} catch (IOException e) {
- log.error("Error while reading number of records in tlog " + this, e);
+ log.error("Error while reading number of records in tlog {}", this, e);
}
return 0;
}
@@ -340,7 +340,7 @@ public class CdcrTransactionLog extends TransactionLog {
public void close() {
try {
if (debug) {
- log.debug("Closing tlog" + this);
+ log.debug("Closing tlog {}", this);
}
synchronized (this) {
@@ -380,7 +380,7 @@ public class CdcrTransactionLog extends TransactionLog {
synchronized void reopenOutputStream() {
try {
if (debug) {
- log.debug("Re-opening tlog's output stream: " + this);
+ log.debug("Re-opening tlog's output stream: {}", this);
}
raf = new RandomAccessFile(this.tlogFile, "rw");
diff --git a/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java b/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
index 6d41b6477fb..19f19478c62 100644
--- a/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
@@ -325,7 +325,7 @@ public class CdcrUpdateLog extends UpdateLog {
id = getLastLogId() + 1; // add 1 since we will create a new log for the next update
if (debug) {
- log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", existing tlogs=" + Arrays.asList(tlogFiles) + ", next id=" + id);
+ log.debug("UpdateHandler init: tlogDir={}, existing tlogs={}, next id={}", tlogDir, Arrays.asList(tlogFiles), id);
}
TransactionLog oldLog = null;
diff --git a/solr/core/src/java/org/apache/solr/update/CommitTracker.java b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
index 65d0bcff76f..86be1f2728b 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitTracker.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
@@ -87,7 +87,7 @@ public final class CommitTracker implements Runnable {
this.softCommit = softCommit;
this.openSearcher = openSearcher;
- log.info(name + " AutoCommit: " + this);
+ log.info("{} AutoCommit: {}", name, this);
}
public boolean getOpenSearcher() {
diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
index 3844040ff07..a3ef4e75763 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -204,14 +204,14 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
if (iw != null) {
if (!rollback) {
try {
- log.debug("Closing old IndexWriter... core=" + coreName);
+ log.debug("Closing old IndexWriter... core= {}", coreName);
iw.close();
} catch (Exception e) {
SolrException.log(log, "Error closing old IndexWriter. core=" + coreName, e);
}
} else {
try {
- log.debug("Rollback old IndexWriter... core=" + coreName);
+ log.debug("Rollback old IndexWriter... core={}", coreName);
iw.rollback();
} catch (Exception e) {
SolrException.log(log, "Error rolling back old IndexWriter. core=" + coreName, e);
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 9bbd8fc486c..1f3dc86f133 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -211,7 +211,9 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
}
private void deleteAll() throws IOException {
- log.info(core.getLogId() + "REMOVING ALL DOCUMENTS FROM INDEX");
+ if (log.isInfoEnabled()) {
+ log.info("{} REMOVING ALL DOCUMENTS FROM INDEX", core.getLogId());
+ }
RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
try {
iw.get().deleteAll();
@@ -354,8 +356,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
private void addAndDelete(AddUpdateCommand cmd, List<UpdateLog.DBQ> deletesAfter) throws IOException {
// this logic is different enough from doNormalUpdate that it's separate
- log.info("Reordered DBQs detected. Update=" + cmd + " DBQs="
- + deletesAfter);
+ log.info("Reordered DBQs detected. Update={} DBQs={}", cmd, deletesAfter);
List<Query> dbqList = new ArrayList<>(deletesAfter.size());
for (UpdateLog.DBQ dbq : deletesAfter) {
try {
@@ -364,7 +365,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
tmpDel.version = -dbq.version;
dbqList.add(getQuery(tmpDel));
} catch (Exception e) {
- log.error("Exception parsing reordered query : " + dbq, e);
+ log.error("Exception parsing reordered query : {}", dbq, e);
}
}
@@ -549,7 +550,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
mergeIndexesCommands.mark();
int rc;
- log.info("start " + cmd);
+ log.info("start {}", cmd);
List<DirectoryReader> readers = cmd.readers;
if (readers != null && readers.size() > 0) {
@@ -586,7 +587,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
boolean error=true;
try {
- log.info("start "+cmd);
+ log.info("start {}", cmd);
RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
try {
SolrIndexWriter.setCommitData(iw.get(), cmd.getVersion());
@@ -634,7 +635,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
solrCoreState.getCommitLock().lock();
}
- log.info("start "+cmd);
+ log.info("start {}", cmd);
// We must cancel pending commits *before* we actually execute the commit.
@@ -769,7 +770,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
boolean error=true;
try {
- log.info("start "+cmd);
+ log.info("start {}", cmd);
rollbackWriter();
@@ -801,7 +802,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
@Override
public void close() throws IOException {
- log.debug("closing " + this);
+ log.debug("closing {}", this);
commitTracker.close();
softCommitTracker.close();
@@ -853,8 +854,10 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
solrCoreState.getCommitLock().lock();
try {
try {
- log.info("Committing on IndexWriter.close() {}.",
- (tryToCommit ? "" : " ... SKIPPED (unnecessary)"));
+ if (log.isInfoEnabled()) {
+ log.info("Committing on IndexWriter.close() {}.",
+ (tryToCommit ? "" : " ... SKIPPED (unnecessary)"));
+ }
if (tryToCommit) {
CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
cmd.openSearcher = false;
diff --git a/solr/core/src/java/org/apache/solr/update/HdfsTransactionLog.java b/solr/core/src/java/org/apache/solr/update/HdfsTransactionLog.java
index 75e350851e9..e2e7a5c3777 100644
--- a/solr/core/src/java/org/apache/solr/update/HdfsTransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/HdfsTransactionLog.java
@@ -118,7 +118,7 @@ public class HdfsTransactionLog extends TransactionLog {
}
} else {
if (start > 0) {
- log.error("New transaction log already exists:" + tlogFile + " size=" + tlogOutStream.size());
+ log.error("New transaction log already exists:{} size={}", tlogFile, tlogOutStream.size());
}
addGlobalStrings(globalStrings);
@@ -267,7 +267,7 @@ public class HdfsTransactionLog extends TransactionLog {
synchronized (this) {
if (fos == null) return;
if (debug) {
- log.debug("Closing output for " + tlogFile);
+ log.debug("Closing output for {}", tlogFile);
}
fos.flushBuffer();
finalLogSize = fos.size();
@@ -402,7 +402,7 @@ public class HdfsTransactionLog extends TransactionLog {
synchronized (HdfsTransactionLog.this) {
if (trace) {
- log.trace("Reading log record. pos="+pos+" currentSize="+getLogSize());
+ log.trace("Reading log record. pos={} currentSize={}", pos, getLogSize());
}
if (pos >= getLogSize()) {
diff --git a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
index 9e8499e9f3f..50fae873ac2 100644
--- a/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/HdfsUpdateLog.java
@@ -123,8 +123,8 @@ public class HdfsUpdateLog extends UpdateLog {
}
} else {
if (debug) {
- log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", next id=" + id +
- " this is a reopen or double init ... nothing else to do.");
+ log.debug("UpdateHandler init: tlogDir={}, next id={} this is a reopen or double init ... nothing else to do."
+ , tlogDir, id);
}
versionInfo.reload();
return;
@@ -171,8 +171,8 @@ public class HdfsUpdateLog extends UpdateLog {
// next update
if (debug) {
- log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", existing tlogs="
- + Arrays.asList(tlogFiles) + ", next id=" + id);
+ log.debug("UpdateHandler init: tlogDir={}, existing tlogs={}, next id={}"
+ , tlogDir, Arrays.asList(tlogFiles), id);
}
TransactionLog oldLog = null;
@@ -203,7 +203,7 @@ public class HdfsUpdateLog extends UpdateLog {
newestLogsOnStartup.addFirst(ll);
} else {
// We're never going to modify old non-recovery logs - no need to hold their output open
- log.info("Closing output for old non-recovery log " + ll);
+ log.info("Closing output for old non-recovery log {}", ll);
ll.closeOutput();
}
}
@@ -211,7 +211,7 @@ public class HdfsUpdateLog extends UpdateLog {
try {
versionInfo = new VersionInfo(this, numVersionBuckets);
} catch (SolrException e) {
- log.error("Unable to use updateLog: " + e.getMessage(), e);
+ log.error("Unable to use updateLog: {}", e.getMessage(), e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to use updateLog: " + e.getMessage(), e);
}
@@ -322,11 +322,11 @@ public class HdfsUpdateLog extends UpdateLog {
try {
boolean s = fs.delete(f, false);
if (!s) {
- log.error("Could not remove old buffer tlog file:" + f);
+ log.error("Could not remove old buffer tlog file:{}", f);
}
} catch (IOException e) {
// No need to bubble up this exception, because it won't cause any problems on recovering
- log.error("Could not remove old buffer tlog file:" + f, e);
+ log.error("Could not remove old buffer tlog file:{}", f, e);
}
}
}
@@ -360,7 +360,7 @@ public class HdfsUpdateLog extends UpdateLog {
Path f = new Path(tlogDir, file);
boolean s = fs.delete(f, false);
if (!s) {
- log.error("Could not remove tlog file:" + f);
+ log.error("Could not remove tlog file:{}", f);
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java b/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java
index c41953372b2..4fb07f77c3e 100644
--- a/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java
+++ b/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java
@@ -31,7 +31,9 @@ public class LoggingInfoStream extends InfoStream {
@Override
public void message(String component, String message) {
- log.info("[" + component + "][" + Thread.currentThread().getName() + "]: " + message);
+ if (log.isInfoEnabled()) {
+ log.info("[{}][{}]: {}", component, Thread.currentThread().getName(), message);
+ }
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java b/solr/core/src/java/org/apache/solr/update/PeerSync.java
index 3a406c0fbd9..f83124ab06d 100644
--- a/solr/core/src/java/org/apache/solr/update/PeerSync.java
+++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java
@@ -174,7 +174,9 @@ public class PeerSync implements SolrMetricProducer {
}
Timer.Context timerContext = null;
try {
- log.info(msg() + "START replicas=" + replicas + " nUpdates=" + nUpdates);
+ if (log.isInfoEnabled()) {
+ log.info("{} START replicas={} nUpdates={}", msg(), replicas, nUpdates);
+ }
// check if we already in sync to begin with
if(doFingerprint && alreadyInSync()) {
@@ -207,7 +209,9 @@ public class PeerSync implements SolrMetricProducer {
} else {
// we have no versions and hence no frame of reference to tell if we can use a peers
// updates to bring us into sync
- log.info(msg() + "DONE. We have no versions. sync failed.");
+ if (log.isInfoEnabled()) {
+ log.info("{} DONE. We have no versions. sync failed.", msg());
+ }
for (;;) {
ShardResponse srsp = shardHandler.takeCompletedOrError();
if (srsp == null) break;
@@ -230,7 +234,9 @@ public class PeerSync implements SolrMetricProducer {
if (srsp == null) break;
boolean success = handleResponse(srsp);
if (!success) {
- log.info(msg() + "DONE. sync failed");
+ if (log.isInfoEnabled()) {
+ log.info("{} DONE. sync failed", msg());
+ }
shardHandler.cancelAll();
syncErrors.inc();
return PeerSyncResult.failure();
@@ -246,7 +252,9 @@ public class PeerSync implements SolrMetricProducer {
}
}
- log.info(msg() + "DONE. sync " + (success ? "succeeded" : "failed"));
+ if (log.isInfoEnabled()) {
+ log.info("{} DONE. sync {}", msg(), (success ? "succeeded" : "failed"));
+ }
if (!success) {
syncErrors.inc();
}
@@ -345,20 +353,28 @@ public class PeerSync implements SolrMetricProducer {
boolean connectTimeoutExceptionInChain = connectTimeoutExceptionInChain(srsp.getException());
if (connectTimeoutExceptionInChain || solrException instanceof ConnectTimeoutException || solrException instanceof SocketTimeoutException
|| solrException instanceof NoHttpResponseException || solrException instanceof SocketException) {
- log.warn(msg() + " couldn't connect to " + srsp.getShardAddress() + ", counting as success", srsp.getException());
+ if (log.isWarnEnabled()) {
+ log.warn("{} couldn't connect to {}, counting as success ", msg(), srsp.getShardAddress(), srsp.getException());
+ }
+
return true;
}
}
if (cantReachIsSuccess && sreq.purpose == 1 && srsp.getException() instanceof SolrException && ((SolrException) srsp.getException()).code() == 503) {
- log.warn(msg() + " got a 503 from " + srsp.getShardAddress() + ", counting as success", srsp.getException());
+ if (log.isWarnEnabled()) {
+ log.warn("{} got a 503 from {}, counting as success "
+ , msg(), srsp.getShardAddress(), srsp.getException());
+ }
return true;
}
if (cantReachIsSuccess && sreq.purpose == 1 && srsp.getException() instanceof SolrException && ((SolrException) srsp.getException()).code() == 404) {
- log.warn(msg() + " got a 404 from " + srsp.getShardAddress() + ", counting as success. " +
- "Perhaps /get is not registered?", srsp.getException());
+ if (log.isWarnEnabled()) {
+ log.warn("{} got a 404 from {}, counting as success. {} Perhaps /get is not registered?"
+ , msg(), srsp.getShardAddress(), srsp.getException());
+ }
return true;
}
@@ -367,8 +383,10 @@ public class PeerSync implements SolrMetricProducer {
// TODO: at least log???
// srsp.getException().printStackTrace(System.out);
-
- log.warn(msg() + " exception talking to " + srsp.getShardAddress() + ", failed", srsp.getException());
+
+ if (log.isWarnEnabled()) {
+ log.warn("{} exception talking to {}, failed", msg(), srsp.getShardAddress(), srsp.getException());
+ }
return false;
}
@@ -430,7 +448,9 @@ public class PeerSync implements SolrMetricProducer {
SyncShardRequest sreq = (SyncShardRequest) srsp.getShardRequest();
Object fingerprint = srsp.getSolrResponse().getResponse().get("fingerprint");
- log.info(msg() + " Received " + otherVersions.size() + " versions from " + sreq.shards[0] + " fingerprint:" + fingerprint );
+ if (log.isInfoEnabled()) {
+ log.info("{} Received {} versions from {} fingerprint:{}", msg(), otherVersions.size(), sreq.shards[0], fingerprint);
+ }
if (fingerprint != null) {
sreq.fingerprint = IndexFingerprint.fromObject(fingerprint);
}
@@ -473,7 +493,7 @@ public class PeerSync implements SolrMetricProducer {
}
return cmp == 0; // currently, we only check for equality...
} catch(IOException e){
- log.error(msg() + "Error getting index fingerprint", e);
+ log.error("{} Error getting index fingerprint", msg(), e);
return false;
}
}
@@ -481,7 +501,9 @@ public class PeerSync implements SolrMetricProducer {
private boolean requestUpdates(ShardResponse srsp, String versionsAndRanges, long totalUpdates) {
String replica = srsp.getShardRequest().shards[0];
- log.info(msg() + "Requesting updates from " + replica + "n=" + totalUpdates + " versions=" + versionsAndRanges);
+ if (log.isInfoEnabled()) {
+ log.info("{} Requesting updates from {} n={} versions={}", msg(), replica, totalUpdates, versionsAndRanges);
+ }
// reuse our original request object
ShardRequest sreq = srsp.getShardRequest();
@@ -508,7 +530,7 @@ public class PeerSync implements SolrMetricProducer {
SyncShardRequest sreq = (SyncShardRequest) srsp.getShardRequest();
if (updates.size() < sreq.totalRequestedUpdates) {
- log.error(msg() + " Requested " + sreq.totalRequestedUpdates + " updates from " + sreq.shards[0] + " but retrieved " + updates.size());
+ log.error("{} Requested {} updates from {} but retrieved {}", msg(), sreq.totalRequestedUpdates, sreq.shards[0], updates.size());
return false;
}
@@ -607,7 +629,7 @@ public class PeerSync implements SolrMetricProducer {
List<Object> entry = (List<Object>)o;
if (debug) {
- log.debug(logPrefix + "raw update record " + o);
+ log.debug("{} raw update record {}", logPrefix, o);
}
int oper = (Integer)entry.get(0) & UpdateLog.OPERATION_MASK;
@@ -626,7 +648,7 @@ public class PeerSync implements SolrMetricProducer {
cmd.setVersion(version);
cmd.setFlags(UpdateCommand.PEER_SYNC | UpdateCommand.IGNORE_AUTOCOMMIT);
if (debug) {
- log.debug(logPrefix + "add " + cmd + " id " + sdoc.getField(ID));
+ log.debug("{} add {} id {}", logPrefix, cmd, sdoc.getField(ID));
}
proc.processAdd(cmd);
break;
@@ -639,7 +661,9 @@ public class PeerSync implements SolrMetricProducer {
cmd.setVersion(version);
cmd.setFlags(UpdateCommand.PEER_SYNC | UpdateCommand.IGNORE_AUTOCOMMIT);
if (debug) {
- log.debug(logPrefix + "delete " + cmd + " " + new BytesRef(idBytes).utf8ToString());
+ if (log.isDebugEnabled()) {
+ log.debug("{} delete {} {}", logPrefix, cmd, new BytesRef(idBytes).utf8ToString());
+ }
}
proc.processDelete(cmd);
break;
@@ -653,7 +677,7 @@ public class PeerSync implements SolrMetricProducer {
cmd.setVersion(version);
cmd.setFlags(UpdateCommand.PEER_SYNC | UpdateCommand.IGNORE_AUTOCOMMIT);
if (debug) {
- log.debug(logPrefix + "deleteByQuery " + cmd);
+ log.debug("{} deleteByQuery {}", logPrefix, cmd);
}
proc.processDelete(cmd);
break;
@@ -663,7 +687,7 @@ public class PeerSync implements SolrMetricProducer {
AddUpdateCommand cmd = UpdateLog.convertTlogEntryToAddUpdateCommand(req, entry, oper, version);
cmd.setFlags(UpdateCommand.PEER_SYNC | UpdateCommand.IGNORE_AUTOCOMMIT);
if (debug) {
- log.debug(logPrefix + "inplace update " + cmd + " prevVersion=" + cmd.prevVersion + ", doc=" + cmd.solrDoc);
+ log.debug("{} inplace update {} prevVersion={} doc={}", logPrefix, cmd, cmd.prevVersion, cmd.solrDoc);
}
proc.processAdd(cmd);
break;
@@ -678,16 +702,16 @@ public class PeerSync implements SolrMetricProducer {
} catch (IOException e) {
// TODO: should this be handled separately as a problem with us?
// I guess it probably already will by causing replication to be kicked off.
- log.error(logPrefix + "Error applying updates from " + updateFrom + " ,update=" + o, e);
+ log.error("{} Error applying updates from {}, update={}", logPrefix, updateFrom, o, e);
throw e;
} catch (Exception e) {
- log.error(logPrefix + "Error applying updates from " + updateFrom + " ,update=" + o, e);
+ log.error("{} Error applying updates from {}, update={} ", logPrefix, updateFrom, o, e);
throw e;
} finally {
try {
proc.finish();
} catch (Exception e) {
- log.error(logPrefix + "Error applying updates from " + updateFrom + " ,finish()", e);
+ log.error("{} Error applying updates from {}, finish()", logPrefix, updateFrom, e);
throw e;
} finally {
IOUtils.closeQuietly(proc);
diff --git a/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java b/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java
index d1c9577b151..e28cd534bae 100644
--- a/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java
+++ b/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java
@@ -132,10 +132,12 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
Timer.Context timerContext = null;
try {
- log.info(msg() + "START leader=" + leaderUrl + " nUpdates=" + nUpdates);
+ if (log.isInfoEnabled()) {
+ log.info("{} START leader={} nUpdates={}", msg(), leaderUrl, nUpdates);
+ }
if (debug) {
- log.debug(msg() + "startingVersions=" + startingVersions.size() + " " + startingVersions);
+ log.debug("{} startingVersions={} {}", msg(), startingVersions.size(), startingVersions);
}
// check if we already in sync to begin with
if(doFingerprint && alreadyInSync()) {
@@ -163,8 +165,9 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
long smallestNewUpdate = Math.abs(ourUpdates.get(ourUpdates.size() - 1));
if (Math.abs(startingVersions.get(0)) < smallestNewUpdate) {
- log.warn(msg()
- + "too many updates received since start - startingUpdates no longer overlaps with our currentUpdates");
+ if (log.isWarnEnabled()) {
+ log.warn("{} too many updates received since start - startingUpdates no longer overlaps with our currentUpdates", msg());
+ }
syncErrors.inc();
return PeerSync.PeerSyncResult.failure();
}
@@ -178,7 +181,9 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
boolean success = doSync(ourUpdates, ourLowThreshold, ourHighThreshold);
- log.info(msg() + "DONE. sync " + (success ? "succeeded" : "failed"));
+ if (log.isInfoEnabled()) {
+ log.info("{} DONE. sync {}", msg(), (success ? "succeeded" : "failed"));
+ }
if (!success) {
syncErrors.inc();
}
@@ -190,7 +195,9 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
try {
clientToLeader.close();
} catch (IOException e) {
- log.warn("{} unable to close client to leader", msg(), e);
+ if (log.isWarnEnabled()) {
+ log.warn("{} unable to close client to leader", msg(), e);
+ }
}
}
}
@@ -226,7 +233,9 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
private MissedUpdatesRequest buildMissedUpdatesRequest(NamedList<Object> rsp) {
// we retrieved the last N updates from the replica
List<Long> otherVersions = (List<Long>)rsp.get("versions");
- log.info(msg() + " Received " + otherVersions.size() + " versions from " + leaderUrl);
+ if (log.isInfoEnabled()) {
+ log.info("{} Received {} versions from {}", msg(), otherVersions.size(), leaderUrl);
+ }
if (otherVersions.isEmpty()) {
return MissedUpdatesRequest.UNABLE_TO_SYNC;
@@ -242,7 +251,10 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
}
private NamedList<Object> requestUpdates(MissedUpdatesRequest missedUpdatesRequest) {
- log.info(msg() + "Requesting updates from " + leaderUrl + " n=" + missedUpdatesRequest.totalRequestedUpdates + " versions=" + missedUpdatesRequest.versionsAndRanges);
+ if (log.isInfoEnabled()) {
+ log.info("{} Requesting updates from {} n={} versions={}", msg(), leaderUrl
+ , missedUpdatesRequest.totalRequestedUpdates, missedUpdatesRequest.versionsAndRanges);
+ }
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/get");
@@ -259,7 +271,7 @@ public class PeerSyncWithLeader implements SolrMetricProducer {
List<Object> updates = (List<Object>)rsp.get("updates");
if (updates.size() < numRequestedUpdates) {
- log.error(msg() + " Requested " + numRequestedUpdates + " updates from " + leaderUrl + " but retrieved " + updates.size());
+ log.error("{} Requested {} updated from {} but retrieved {}", msg(), numRequestedUpdates, leaderUrl, updates.size());
return false;
}
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index e4727dab2af..a12029338e0 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -131,7 +131,7 @@ public class SolrCmdDistributor implements Closeable {
builder.append(errors.size() - 10);
builder.append(" more");
}
- log.debug(builder.toString());
+ log.debug("{}", builder);
}
for (Error err : errors) {
@@ -162,7 +162,9 @@ public class SolrCmdDistributor implements Closeable {
// Only backoff once for the full batch
try {
int backoffTime = Math.min(retryPause * resubmitList.get(0).req.retries, 2000);
- log.debug("Sleeping {}ms before re-submitting {} requests", backoffTime, resubmitList.size());
+ if (log.isDebugEnabled()) {
+ log.debug("Sleeping {}ms before re-submitting {} requests", backoffTime, resubmitList.size());
+ }
Thread.sleep(backoffTime);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
index b56bcb6ef53..44bf3143d10 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
@@ -196,8 +196,9 @@ public class SolrIndexSplitter {
t = timings.sub("parentApplyBufferedUpdates");
ulog.applyBufferedUpdates();
t.stop();
- log.info("Splitting in 'link' mode " + (success? "finished" : "FAILED") +
- ": re-opened parent IndexWriter.");
+ if (log.isInfoEnabled()) {
+ log.info("Splitting in 'link' mode {}: re-opened parent IndexWriter.", (success ? "finished" : "FAILED"));
+ }
}
}
results.add(CommonParams.TIMING, timings.asNamedList());
@@ -211,7 +212,9 @@ public class SolrIndexSplitter {
SolrIndexConfig parentConfig = searcher.getCore().getSolrConfig().indexConfig;
String timestamp = new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.ROOT).format(new Date());
- log.info("SolrIndexSplitter: partitions=" + numPieces + " segments=" + leaves.size());
+ if (log.isInfoEnabled()) {
+ log.info("SolrIndexSplitter: partitions={} segments={}", numPieces, leaves.size());
+ }
RTimerTree t;
// this tracks round-robin assignment of docs to partitions
@@ -307,7 +310,11 @@ public class SolrIndexSplitter {
t = timings.sub("addIndexes");
t.resume();
for (int segmentNumber = 0; segmentNumber<leaves.size(); segmentNumber++) {
- log.info("SolrIndexSplitter: partition #" + partitionNumber + " partitionCount=" + numPieces + (ranges != null ? " range=" + ranges.get(partitionNumber) : "") + " segment #"+segmentNumber + " segmentCount=" + leaves.size());
+ if (log.isInfoEnabled()) {
+ log.info("SolrIndexSplitter: partition #{} partitionCount={} segment #{} segmentCount={}"
+ , partitionNumber, numPieces + (ranges != null ? " range=" + ranges.get(partitionNumber) : "")
+ , segmentNumber, leaves.size());
+ }
CodecReader subReader = SlowCodecReaderWrapper.wrap(leaves.get(segmentNumber).reader());
iw.addIndexes(new LiveDocsReader(subReader, segmentDocSets.get(segmentNumber)[partitionNumber]));
}
@@ -358,7 +365,7 @@ public class SolrIndexSplitter {
subCore.getUpdateHandler().newIndexWriter(false);
openNewSearcher(subCore);
} catch (Exception e) {
- log.error("Failed to switch sub-core " + indexDirPath + " to " + hardLinkPath + ", split will fail.", e);
+ log.error("Failed to switch sub-core {} to {}, split will fail", indexDirPath, hardLinkPath, e);
switchOk = false;
break;
}
@@ -395,7 +402,7 @@ public class SolrIndexSplitter {
try {
openNewSearcher(subCore);
} catch (Exception e) {
- log.warn("Error rolling back failed split of " + hardLinkPath, e);
+ log.warn("Error rolling back failed split of {}", hardLinkPath, e);
}
}
t.stop();
@@ -461,8 +468,11 @@ public class SolrIndexSplitter {
t.resume();
FixedBitSet set = findDocsToDelete(context);
t.pause();
- log.info("### partition=" + partition + ", leaf=" + context + ", maxDoc=" + context.reader().maxDoc() +
- ", numDels=" + context.reader().numDeletedDocs() + ", setLen=" + set.length() + ", setCard=" + set.cardinality());
+ if (log.isInfoEnabled()) {
+ log.info("### partition={}, leaf={}, maxDoc={}, numDels={}, setLen={}, setCard={}"
+ , partition, context, context.reader().maxDoc()
+ ,context.reader().numDeletedDocs(), set.length(), set.cardinality());
+ }
Bits liveDocs = context.reader().getLiveDocs();
if (liveDocs != null) {
// check that we don't delete already deleted docs
@@ -470,7 +480,7 @@ public class SolrIndexSplitter {
dels.flip(0, dels.length());
dels.and(set);
if (dels.cardinality() > 0) {
- log.error("### INVALID DELS " + dels.cardinality());
+ log.error("### INVALID DELS {}", dels.cardinality());
}
}
return new ConstantScoreScorer(this, score(), scoreMode, new BitSetIterator(set, set.length()));
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
index 4070ea91643..8a0ccb15147 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
@@ -115,7 +115,7 @@ public class SolrIndexWriter extends IndexWriter {
this.infoStream = conf.getInfoStream();
this.directory = d;
numOpens.incrementAndGet();
- log.debug("Opened Writer " + name);
+ log.debug("Opened Writer {}", name);
// no metrics
mergeTotals = false;
mergeDetails = false;
@@ -128,7 +128,7 @@ public class SolrIndexWriter extends IndexWriter {
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
setIndexDeletionPolicy(delPolicy).setCodec(codec)
);
- log.debug("Opened Writer " + name);
+ log.debug("Opened Writer {}", name);
this.name = name;
infoStream = getConfig().getInfoStream();
this.directory = directory;
@@ -179,7 +179,7 @@ public class SolrIndexWriter extends IndexWriter {
@SuppressForbidden(reason = "Need currentTimeMillis, commit time should be used only for debugging purposes, " +
" but currently suspiciously used for replication as well")
public static void setCommitData(IndexWriter iw, long commitCommandVersion) {
- log.info("Calling setCommitData with IW:" + iw.toString() + " commitCommandVersion:"+commitCommandVersion);
+ log.info("Calling setCommitData with IW:{} commitCommandVersion:{}", iw, commitCommandVersion);
final Map<String,String> commitData = new HashMap<>();
commitData.put(COMMIT_TIME_MSEC_KEY, String.valueOf(System.currentTimeMillis()));
commitData.put(COMMIT_COMMAND_VERSION, String.valueOf(commitCommandVersion));
@@ -293,7 +293,7 @@ public class SolrIndexWriter extends IndexWriter {
@Override
public void close() throws IOException {
- log.debug("Closing Writer " + name);
+ log.debug("Closing Writer {}", name);
try {
super.close();
} catch (Throwable t) {
@@ -308,7 +308,7 @@ public class SolrIndexWriter extends IndexWriter {
@Override
public void rollback() throws IOException {
- log.debug("Rollback Writer " + name);
+ log.debug("Rollback Writer {}", name);
try {
super.rollback();
} catch (Throwable t) {
diff --git a/solr/core/src/java/org/apache/solr/update/TransactionLog.java b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
index b4db6ef0cb0..9fe4e9386ce 100644
--- a/solr/core/src/java/org/apache/solr/update/TransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
@@ -166,7 +166,8 @@ public class TransactionLog implements Closeable {
boolean success = false;
try {
if (debug) {
- log.debug("New TransactionLog file=" + tlogFile + ", exists=" + tlogFile.exists() + ", size=" + tlogFile.length() + ", openExisting=" + openExisting);
+ log.debug("New TransactionLog file= {}, exists={}, size={} openExisting={}"
+ , tlogFile, tlogFile.exists(), tlogFile.length(), openExisting);
}
// Parse tlog id from the filename
@@ -193,7 +194,9 @@ public class TransactionLog implements Closeable {
}
} else {
if (start > 0) {
- log.warn("New transaction log already exists:" + tlogFile + " size=" + raf.length());
+ if (log.isWarnEnabled()) {
+ log.warn("New transaction log already exists:{} size={}", tlogFile, raf.length());
+ }
return;
}
@@ -580,7 +583,7 @@ public class TransactionLog implements Closeable {
public void close() {
try {
if (debug) {
- log.debug("Closing tlog" + this);
+ log.debug("Closing tlog {}", this);
}
synchronized (this) {
@@ -605,7 +608,7 @@ public class TransactionLog implements Closeable {
public void forceClose() {
if (refcount.get() > 0) {
- log.error("Error: Forcing close of " + this);
+ log.error("Error: Forcing close of {}", this);
refcount.set(0);
close();
}
@@ -668,7 +671,7 @@ public class TransactionLog implements Closeable {
synchronized (TransactionLog.this) {
if (trace) {
- log.trace("Reading log record. pos="+pos+" currentSize="+fos.size());
+ log.trace("Reading log record. pos={} currentSize={}", pos, fos.size());
}
if (pos >= fos.size()) {
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index 0b122a4c470..37397f7edf4 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -64,11 +64,11 @@ public abstract class UpdateHandler implements SolrInfoBean {
if ("postCommit".equals(event)) {
SolrEventListener obj = core.createInitInstance(info,clazz,label,null);
commitCallbacks.add(obj);
- log.info("added SolrEventListener for postCommit: " + obj);
+ log.info("added SolrEventListener for postCommit: {}", obj);
} else if ("postOptimize".equals(event)) {
SolrEventListener obj = core.createInitInstance(info,clazz,label,null);
optimizeCallbacks.add(obj);
- log.info("added SolrEventListener for postOptimize: " + obj);
+ log.info("added SolrEventListener for postOptimize: {}", obj);
}
}
}
@@ -133,7 +133,9 @@ public abstract class UpdateHandler implements SolrInfoBean {
ulog.clearLog(core, ulogPluginInfo);
}
- log.info("Using UpdateLog implementation: " + ulog.getClass().getName());
+ if (log.isInfoEnabled()) {
+ log.info("Using UpdateLog implementation: {}", ulog.getClass().getName());
+ }
ulog.init(ulogPluginInfo);
ulog.init(this, core);
} else {
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 6620ea108ef..7a6876daf49 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -116,7 +116,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
try{
return SyncLevel.valueOf(level.toUpperCase(Locale.ROOT));
} catch(Exception ex){
- log.warn("There was an error reading the SyncLevel - default to " + SyncLevel.FLUSH, ex);
+ log.warn("There was an error reading the SyncLevel - default to {}", SyncLevel.FLUSH, ex);
return SyncLevel.FLUSH;
}
}
@@ -362,7 +362,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
core.getCoreMetricManager().registerMetricProducer(SolrInfoBean.Category.TLOG.toString(), this);
if (debug) {
- log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", next id=" + id + " this is a reopen... nothing else to do.");
+ log.debug("UpdateHandler init: tlogDir={}, next id={} this is a reopen...nothing else to do", tlogDir, id);
}
return;
}
@@ -373,7 +373,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
id = getLastLogId() + 1; // add 1 since we will create a new log for the next update
if (debug) {
- log.debug("UpdateHandler init: tlogDir=" + tlogDir + ", existing tlogs=" + Arrays.asList(tlogFiles) + ", next id=" + id);
+ log.debug("UpdateHandler init: tlogDir={}, existing tlogs={}, next id={}", tlogDir, Arrays.asList(tlogFiles), id);
}
String[] oldBufferTlog = getBufferLogList(tlogDir);
@@ -402,7 +402,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
try {
versionInfo = new VersionInfo(this, numVersionBuckets);
} catch (SolrException e) {
- log.error("Unable to use updateLog: " + e.getMessage(), e);
+ log.error("Unable to use updateLog: {}", e.getMessage(), e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to use updateLog: " + e.getMessage(), e);
}
@@ -584,13 +584,13 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
map.put(cmd.getIndexedId(), ptr);
if (trace) {
- log.trace("TLOG: added id " + cmd.getPrintableId() + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ log.trace("TLOG: added id {} to {} {} map={}", cmd.getPrintableId(), tlog, ptr, System.identityHashCode(map));
}
} else {
openRealtimeSearcher();
- if (trace) {
- log.trace("TLOG: added id " + cmd.getPrintableId() + " to " + tlog + " clearCaches=true");
+ if (log.isTraceEnabled()) {
+ log.trace("TLOG: added id {} to {} clearCaches=true", cmd.getPrintableId(), tlog);
}
}
@@ -645,7 +645,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
oldDeletes.put(br, ptr);
if (trace) {
- log.trace("TLOG: added delete for id " + cmd.id + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ log.trace("TLOG: added delete for id {} to {} {} map={}", cmd.id, tlog, ptr, System.identityHashCode(map));
}
}
}
@@ -673,7 +673,8 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
if (trace) {
LogPtr ptr = new LogPtr(pos, cmd.getVersion());
- log.trace("TLOG: added deleteByQuery " + cmd.query + " to " + tlog + " " + ptr + " map=" + System.identityHashCode(map));
+ int hash = System.identityHashCode(map);
+ log.trace("TLOG: added deleteByQuery {} to {} {} map = {}.", cmd.query, tlog, ptr, hash);
}
}
}
@@ -859,7 +860,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
map = new HashMap<>();
if (debug) {
- log.debug("TLOG: preSoftCommit: prevMap="+ System.identityHashCode(prevMap) + " new map=" + System.identityHashCode(map));
+ log.debug("TLOG: preSoftCommit: prevMap={} new map={}", System.identityHashCode(prevMap), System.identityHashCode(map));
}
}
}
@@ -971,8 +972,8 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
// This can happen when trying to deserialize the entry at position lookupPointer,
// but from a different tlog than the one containing the desired entry.
// Just ignore the exception, so as to proceed to the next tlog.
- log.debug("Exception reading the log (this is expected, don't worry)=" + lookupLog + ", for version=" + lookupVersion +
- ". This can be ignored.");
+ log.debug("Exception reading the log (this is expected, don't worry)={}, for version={}. This can be ignored"
+ , lookupLog, lookupVersion);
}
if (obj != null && obj instanceof List) {
@@ -1115,7 +1116,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
continue;
}
} catch (IOException e) {
- log.error("Error inspecting tlog " + ll, e);
+ log.error("Error inspecting tlog {}", ll, e);
ll.closeOutput();
ll.decref();
continue;
@@ -1292,7 +1293,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
}
}
} catch (ClassCastException e) {
- log.warn("Unexpected log entry or corrupt log. Entry=" + o, e);
+ log.warn("Unexpected log entry or corrupt log. Entry={}", o, e);
}
}
// Prev tlog will be closed, so nullify prevMap
@@ -1338,7 +1339,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
if (theLog != null) {
if (writeCommit) {
// record a commit
- log.info("Recording current closed for " + uhandler.core + " log=" + theLog);
+ log.info("Recording current closed for {} log={}", uhandler.core, theLog);
CommitUpdateCommand cmd = new CommitUpdateCommand(new LocalSolrQueryRequest(uhandler.core, new ModifiableSolrParams((SolrParams)null)), false);
theLog.writeCommit(cmd);
}
@@ -1532,7 +1533,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown Operation! " + oper);
}
} catch (ClassCastException cl) {
- log.warn("Unexpected log entry or corrupt log. Entry=" + o, cl);
+ log.warn("Unexpected log entry or corrupt log. Entry={}", o, cl);
// would be caused by a corrupt transaction log
} catch (Exception ex) {
log.warn("Exception reverse reading log", ex);
@@ -1610,7 +1611,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
try {
if (state != State.ACTIVE && state != State.BUFFERING) {
// we don't currently have support for handling other states
- log.warn("Unexpected state for bufferUpdates: " + state + ", Ignoring request.");
+ log.warn("Unexpected state for bufferUpdates: {}, Ignoring request", state);
return;
}
dropBufferTlog();
@@ -1619,7 +1620,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
recoveryInfo = new RecoveryInfo();
if (log.isInfoEnabled()) {
- log.info("Starting to buffer updates. " + this);
+ log.info("Starting to buffer updates. {}", this);
}
state = State.BUFFERING;
@@ -1635,7 +1636,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
if (state != State.BUFFERING) return false;
if (log.isInfoEnabled()) {
- log.info("Dropping buffered updates " + this);
+ log.info("Dropping buffered updates {}", this);
}
dropBufferTlog();
@@ -1778,12 +1779,12 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
// clean up in case we hit some unexpected exception and didn't get
// to more transaction logs
for (TransactionLog translog : translogs) {
- log.error("ERROR: didn't get to recover from tlog " + translog);
+ log.error("ERROR: didn't get to recover from tlog {}", translog);
translog.decref();
}
}
- loglog.warn("Log replay finished. recoveryInfo=" + recoveryInfo);
+ loglog.warn("Log replay finished. recoveryInfo={}", recoveryInfo);
if (testing_logReplayFinishHook != null) testing_logReplayFinishHook.run();
@@ -1793,7 +1794,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
public void doReplay(TransactionLog translog) {
try {
- loglog.warn("Starting log replay " + translog + " active=" + activeLog + " starting pos=" + recoveryInfo.positionOfStart + " inSortedOrder=" + inSortedOrder);
+ loglog.warn("Starting log replay {} active={} starting pos={} inSortedOrder={}", translog, activeLog, recoveryInfo.positionOfStart, inSortedOrder);
long lastStatusTime = System.nanoTime();
if (inSortedOrder) {
tlogReader = translog.getSortedReader(recoveryInfo.positionOfStart);
@@ -1825,10 +1826,12 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
lastStatusTime = now;
long cpos = tlogReader.currentPos();
long csize = tlogReader.currentSize();
- loglog.info(
- "log replay status {} active={} starting pos={} current pos={} current size={} % read={}",
- translog, activeLog, recoveryInfo.positionOfStart, cpos, csize,
- Math.floor(cpos / (double) csize * 100.));
+ if (log.isInfoEnabled()) {
+ loglog.info(
+ "log replay status {} active={} starting pos={} current pos={} current size={} % read={}",
+ translog, activeLog, recoveryInfo.positionOfStart, cpos, csize,
+ Math.floor(cpos / (double) csize * 100.));
+ }
}
}
@@ -1894,7 +1897,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
cmd.setIndexedId(new BytesRef(idBytes));
cmd.setVersion(version);
cmd.setFlags(UpdateCommand.REPLAY | UpdateCommand.IGNORE_AUTOCOMMIT);
- if (debug) log.debug("delete " + cmd);
+ if (debug) log.debug("delete {}", cmd);
execute(cmd, executor, pendingTasks, proc, exceptionOnExecuteUpdate);
break;
}
@@ -1906,7 +1909,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
cmd.query = query;
cmd.setVersion(version);
cmd.setFlags(UpdateCommand.REPLAY | UpdateCommand.IGNORE_AUTOCOMMIT);
- if (debug) log.debug("deleteByQuery " + cmd);
+ if (debug) log.debug("deleteByQuery {}", cmd);
waitForAllUpdatesGetExecuted(pendingTasks);
// DBQ will be executed in the same thread
execute(cmd, null, pendingTasks, proc, exceptionOnExecuteUpdate);
@@ -1922,7 +1925,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
}
if (rsp.getException() != null) {
- loglog.error("REPLAY_ERR: Exception replaying log", rsp.getException());
+ loglog.error("REPLAY_ERR: Exception replaying log {}", rsp.getException());
throw rsp.getException();
}
if (state == State.REPLAYING) {
@@ -1934,7 +1937,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
}
} catch (ClassCastException cl) {
recoveryInfo.errors++;
- loglog.warn("REPLAY_ERR: Unexpected log entry or corrupt log. Entry=" + o, cl);
+ loglog.warn("REPLAY_ERR: Unexpected log entry or corrupt log. Entry={}", o, cl);
// would be caused by a corrupt transaction log
} catch (Exception ex) {
recoveryInfo.errors++;
@@ -1953,7 +1956,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
cmd.waitSearcher = true;
cmd.setFlags(UpdateCommand.REPLAY);
try {
- if (debug) log.debug("commit " + cmd);
+ if (debug) log.debug("commit {}", cmd);
uhandler.commit(cmd); // this should cause a commit to be added to the incomplete log and avoid it being replayed again after a restart.
} catch (IOException ex) {
recoveryInfo.errors++;
@@ -2105,14 +2108,14 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
Files.deleteIfExists(file.toPath());
success = true;
} catch (Exception e) {
- log.error("Error deleting file: " + file, e);
+ log.error("Error deleting file: {}", file, e);
}
if (!success) {
try {
file.deleteOnExit();
} catch (Exception e) {
- log.error("Error deleting file on exit: " + file, e);
+ log.error("Error deleting file on exit: {}", file, e);
}
}
}
@@ -2149,7 +2152,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
Files.delete(f.toPath());
} catch (IOException cause) {
// NOTE: still throws SecurityException as before.
- log.error("Could not remove tlog file:" + f, cause);
+ log.error("Could not remove tlog file:{}", f, cause);
}
}
}
@@ -2196,11 +2199,13 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
highestVersion = maxVersion;
} catch (IOException ioExc) {
- log.warn("Failed to determine the max value of the version field due to: "+ioExc, ioExc);
+ log.warn("Failed to determine the max value of the version field due to: ", ioExc);
}
- log.debug("Took {}ms to seed version buckets with highest version {}",
- timer.getTime(), String.valueOf(highestVersion));
+ if (debug) {
+ log.debug("Took {}ms to seed version buckets with highest version {}",
+ timer.getTime(), highestVersion);
+ }
return highestVersion;
}
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
index fddc972ede6..5d960fb6fe8 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
@@ -138,7 +138,9 @@ public class UpdateShardHandler implements SolrInfoBean {
ThreadFactory recoveryThreadFactory = new SolrNamedThreadFactory("recoveryExecutor");
if (cfg != null && cfg.getMaxRecoveryThreads() > 0) {
- log.debug("Creating recoveryExecutor with pool size {}", cfg.getMaxRecoveryThreads());
+ if (log.isDebugEnabled()) {
+ log.debug("Creating recoveryExecutor with pool size {}", cfg.getMaxRecoveryThreads());
+ }
recoveryExecutor = ExecutorUtil.newMDCAwareFixedThreadPool(cfg.getMaxRecoveryThreads(), recoveryThreadFactory);
} else {
log.debug("Creating recoveryExecutor with unbounded pool");
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
index 6d102d73505..b6239f6787f 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactory.java
@@ -438,7 +438,7 @@ public class AddSchemaFieldsUpdateProcessorFactory extends UpdateRequestProcesso
builder.append("}");
}
builder.append("]");
- log.debug(builder.toString());
+ log.debug("{}", builder);
}
// Need to hold the lock during the entire attempt to ensure that
// the schema on the request is the latest
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AllValuesOrNoneFieldMutatingUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/AllValuesOrNoneFieldMutatingUpdateProcessor.java
index 1d56a62d485..bf1da4c4d42 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AllValuesOrNoneFieldMutatingUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AllValuesOrNoneFieldMutatingUpdateProcessor.java
@@ -83,8 +83,10 @@ public abstract class AllValuesOrNoneFieldMutatingUpdateProcessor extends FieldM
for (final Object srcVal : vals) {
final Object destVal = mutateValue(srcVal);
if (SKIP_FIELD_VALUE_LIST_SINGLETON == destVal) {
- log.debug("field '{}' {} value '{}' is not mutable, so no values will be mutated",
- new Object[] { srcField.getName(), srcVal.getClass().getSimpleName(), srcVal });
+ if (log.isDebugEnabled()) {
+ log.debug("field '{}' {} value '{}' is not mutable, so no values will be mutated",
+ new Object[]{srcField.getName(), srcVal.getClass().getSimpleName(), srcVal});
+ }
return srcField;
}
if (DELETE_VALUE_SINGLETON == destVal) {
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
index 99cb1e1a863..52f208dc50d 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
@@ -172,8 +172,10 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactory
"Atomic update failed after multiple attempts due to " + e.getMessage());
}
if (e.code() == ErrorCode.CONFLICT.code) { // version conflict
- log.warn("Atomic update failed due to " + e.getMessage() +
- " Retrying with new version .... (" + attempts + ")");
+ if (log.isWarnEnabled()) {
+ log.warn("Atomic update failed due to {} Retrying with new version .... ({})"
+ , e.getMessage(), attempts);
+ }
Long lastVersion = vinfo.lookupVersion(cmd.getIndexedId());
// if lastVersion is null then we put -1 to assert that document must not exist
diff --git a/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java
index f0f3308904d..e2b7a58d2d6 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java
@@ -434,8 +434,10 @@ public class CloneFieldUpdateProcessorFactory
if (matcher.find()) {
resolvedDest = matcher.replaceAll(dest);
} else {
- log.debug("CloneFieldUpdateProcessor.srcSelector.shouldMutate(\"{}\") returned true, " +
- "but replacement pattern did not match, field skipped.", fname);
+ if (log.isDebugEnabled()) {
+ log.debug("CloneFieldUpdateProcessor.srcSelector.shouldMutate('{}') returned true, " +
+ "but replacement pattern did not match, field skipped.", fname);
+ }
continue;
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 72021b17b27..4fb5107d6c2 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -366,7 +366,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (forwardedFromCollection && ulog.getState() == UpdateLog.State.ACTIVE) {
// forwarded from a collection but we are not buffering so strip original version and apply our own
// see SOLR-5308
- log.info("Removing version field from doc: " + cmd.getPrintableId());
+ if (log.isInfoEnabled()) {
+ log.info("Removing version field from doc: {}", cmd.getPrintableId());
+ }
cmd.solrDoc.remove(CommonParams.VERSION_FIELD);
versionOnUpdate = 0;
}
@@ -377,7 +379,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (forwardedFromCollection && ulog.getState() != UpdateLog.State.ACTIVE
&& isReplayOrPeersync == false) {
// we're not in an active state, and this update isn't from a replay, so buffer it.
- log.info("Leader logic applied but update log is buffering: " + cmd.getPrintableId());
+ if (log.isInfoEnabled()) {
+ log.info("Leader logic applied but update log is buffering: {}", cmd.getPrintableId());
+ }
cmd.setFlags(cmd.getFlags() | UpdateCommand.BUFFERING);
ulog.add(cmd);
return true;
@@ -427,18 +431,21 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
UpdateCommand fetchedFromLeader = fetchFullUpdateFromLeader(cmd, versionOnUpdate);
if (fetchedFromLeader instanceof DeleteUpdateCommand) {
- log.info("In-place update of {} failed to find valid lastVersion to apply to, and the document"
- + " was deleted at the leader subsequently.", idBytes.utf8ToString());
+ if (log.isInfoEnabled()) {
+ log.info("In-place update of {} failed to find valid lastVersion to apply to, and the document"
+ + " was deleted at the leader subsequently.", idBytes.utf8ToString());
+ }
versionDelete((DeleteUpdateCommand) fetchedFromLeader);
return true;
} else {
assert fetchedFromLeader instanceof AddUpdateCommand;
// Newer document was fetched from the leader. Apply that document instead of this current in-place
// update.
- log.info(
- "In-place update of {} failed to find valid lastVersion to apply to, forced to fetch full doc from leader: {}",
- idBytes.utf8ToString(), fetchedFromLeader);
-
+ if (log.isInfoEnabled()) {
+ log.info(
+ "In-place update of {} failed to find valid lastVersion to apply to, forced to fetch full doc from leader: {}",
+ idBytes.utf8ToString(), fetchedFromLeader);
+ }
// Make this update to become a non-inplace update containing the full document obtained from the
// leader
cmd.solrDoc = ((AddUpdateCommand) fetchedFromLeader).solrDoc;
@@ -450,8 +457,8 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (lastVersion != null && Math.abs(lastVersion) > prev) {
// this means we got a newer full doc update and in that case it makes no sense to apply the older
// inplace update. Drop this update
- log.info("Update was applied on version: " + prev + ", but last version I have is: " + lastVersion
- + ". Dropping current update.");
+ log.info("Update was applied on version: {}, but last version I have is: {}. Dropping current update"
+ , prev, lastVersion);
return true;
} else {
// We're good, we should apply this update. First, update the bucket's highest.
@@ -472,7 +479,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
Long lastVersion = vinfo.lookupVersion(cmd.getIndexedId());
if (lastVersion != null && Math.abs(lastVersion) >= versionOnUpdate) {
// This update is a repeat, or was reordered. We need to drop this update.
- log.debug("Dropping add update due to version {}", idBytes.utf8ToString());
+ if (log.isDebugEnabled()) {
+ log.debug("Dropping add update due to version {}", idBytes.utf8ToString());
+ }
return true;
}
}
@@ -562,20 +571,29 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
// We have waited enough, but dependent update didn't arrive. Its time to actively fetch it from leader
- log.info("Missing update, on which current in-place update depends on, hasn't arrived. id={}, looking for version={}, last found version={}",
- cmd.getPrintableId(), cmd.prevVersion, lastFoundVersion);
+ if (log.isInfoEnabled()) {
+ log.info("Missing update, on which current in-place update depends on, hasn't arrived. id={}, looking for version={}, last found version={}",
+ cmd.getPrintableId(), cmd.prevVersion, lastFoundVersion);
+ }
UpdateCommand missingUpdate = fetchFullUpdateFromLeader(cmd, versionOnUpdate);
if (missingUpdate instanceof DeleteUpdateCommand) {
- log.info("Tried to fetch document {} from the leader, but the leader says document has been deleted. "
- + "Deleting the document here and skipping this update: Last found version: {}, was looking for: {}", cmd.getPrintableId(), lastFoundVersion, cmd.prevVersion);
- versionDelete((DeleteUpdateCommand)missingUpdate);
+ if (log.isInfoEnabled()) {
+ log.info("Tried to fetch document {} from the leader, but the leader says document has been deleted. "
+ + "Deleting the document here and skipping this update: Last found version: {}, was looking for: {}", cmd.getPrintableId(), lastFoundVersion, cmd.prevVersion);
+ versionDelete((DeleteUpdateCommand) missingUpdate);
+ }
return -1;
} else {
assert missingUpdate instanceof AddUpdateCommand;
- log.debug("Fetched the document: {}", ((AddUpdateCommand)missingUpdate).getSolrInputDocument());
+ if (log.isDebugEnabled()) {
+ log.debug("Fetched the document: {}", ((AddUpdateCommand) missingUpdate).getSolrInputDocument());
+ }
versionAdd((AddUpdateCommand)missingUpdate);
- log.info("Added the fetched document, id="+((AddUpdateCommand)missingUpdate).getPrintableId()+", version="+missingUpdate.getVersion());
+ if (log.isInfoEnabled()) {
+ log.info("Added the fetched document, id= {}, version={}"
+ , ((AddUpdateCommand) missingUpdate).getPrintableId(), missingUpdate.getVersion());
+ }
}
return missingUpdate.getVersion();
}
@@ -588,9 +606,11 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
lastFoundVersion = lookedUpVersion == null ? 0L : lookedUpVersion;
if (Math.abs(lastFoundVersion) < cmd.prevVersion) {
- log.debug("Re-ordered inplace update. version={}, prevVersion={}, lastVersion={}, replayOrPeerSync={}, id={}",
- (cmd.getVersion() == 0 ? versionOnUpdate : cmd.getVersion()), cmd.prevVersion, lastFoundVersion,
- isReplayOrPeersync, cmd.getPrintableId());
+ if (log.isDebugEnabled()) {
+ log.debug("Re-ordered inplace update. version={}, prevVersion={}, lastVersion={}, replayOrPeerSync={}, id={}",
+ (cmd.getVersion() == 0 ? versionOnUpdate : cmd.getVersion()), cmd.prevVersion, lastFoundVersion,
+ isReplayOrPeersync, cmd.getPrintableId());
+ }
}
while (Math.abs(lastFoundVersion) < cmd.prevVersion && !waitTimeout.hasTimedOut()) {
@@ -985,7 +1005,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (forwardedFromCollection && ulog.getState() == UpdateLog.State.ACTIVE) {
// forwarded from a collection but we are not buffering so strip original version and apply our own
// see SOLR-5308
- log.info("Removing version field from doc: " + cmd.getId());
+ if (log.isInfoEnabled()) {
+ log.info("Removing version field from doc: {}", cmd.getId());
+ }
versionOnUpdate = signedVersionOnUpdate = 0;
}
@@ -993,7 +1015,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (forwardedFromCollection && ulog.getState() != UpdateLog.State.ACTIVE
&& !isReplayOrPeersync) {
// we're not in an active state, and this update isn't from a replay, so buffer it.
- log.info("Leader logic applied but update log is buffering: " + cmd.getId());
+ if (log.isInfoEnabled()) {
+ log.info("Leader logic applied but update log is buffering: {}", cmd.getId());
+ }
cmd.setFlags(cmd.getFlags() | UpdateCommand.BUFFERING);
ulog.delete(cmd);
return true;
@@ -1036,7 +1060,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
Long lastVersion = vinfo.lookupVersion(cmd.getIndexedId());
if (lastVersion != null && Math.abs(lastVersion) >= versionOnUpdate) {
// This update is a repeat, or was reordered. We need to drop this update.
- log.debug("Dropping delete update due to version {}", idBytes.utf8ToString());
+ if (log.isDebugEnabled()) {
+ log.debug("Dropping delete update due to version {}", idBytes.utf8ToString());
+ }
return true;
}
}
@@ -1078,7 +1104,10 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
if (ulog == null || ulog.getState() == UpdateLog.State.ACTIVE || (cmd.getFlags() & UpdateCommand.REPLAY) != 0) {
super.processCommit(cmd);
} else {
- log.info("Ignoring commit while not ACTIVE - state: " + ulog.getState() + " replay: " + ((cmd.getFlags() & UpdateCommand.REPLAY) != 0));
+ if (log.isInfoEnabled()) {
+ log.info("Ignoring commit while not ACTIVE - state: {} replay: {}"
+ , ulog.getState(), ((cmd.getFlags() & UpdateCommand.REPLAY) != 0));
+ }
}
} finally {
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
index 569f877bb88..64947aba6c5 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
@@ -182,7 +182,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
if (!isLeader && req.getParams().get(COMMIT_END_POINT, "").equals("replicas")) {
if (replicaType == Replica.Type.PULL) {
- log.warn("Commit not supported on replicas of type " + Replica.Type.PULL);
+ log.warn("Commit not supported on replicas of type {}", Replica.Type.PULL);
} else if (replicaType == Replica.Type.NRT) {
doLocalCommit(cmd);
}
@@ -681,7 +681,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
if (skipList != null) {
skipListSet = new HashSet<>(skipList.length);
skipListSet.addAll(Arrays.asList(skipList));
- log.info("test.distrib.skip.servers was found and contains:" + skipListSet);
+ log.info("test.distrib.skip.servers was found and contains:{}", skipListSet);
}
List<SolrCmdDistributor.Node> nodes = new ArrayList<>(replicas.size());
@@ -690,9 +690,13 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
for (Replica replica: replicas) {
String coreNodeName = replica.getName();
if (skipList != null && skipListSet.contains(replica.getCoreUrl())) {
- log.info("check url:" + replica.getCoreUrl() + " against:" + skipListSet + " result:true");
+ if (log.isInfoEnabled()) {
+ log.info("check url:{} against:{} result:true", replica.getCoreUrl(), skipListSet);
+ }
} else if(zkShardTerms.registered(coreNodeName) && zkShardTerms.skipSendingUpdatesTo(coreNodeName)) {
- log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl());
+ if (log.isDebugEnabled()) {
+ log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl());
+ }
skippedCoreNodeNames.add(replica.getName());
} else if (!clusterState.getLiveNodes().contains(replica.getNodeName()) || replica.getState() == Replica.State.DOWN) {
skippedCoreNodeNames.add(replica.getName());
@@ -833,7 +837,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
if (skipList != null) {
skipListSet = new HashSet<>(skipList.length);
skipListSet.addAll(Arrays.asList(skipList));
- log.info("test.distrib.skip.servers was found and contains:" + skipListSet);
+ log.info("test.distrib.skip.servers was found and contains:{}", skipListSet);
}
List<SolrCmdDistributor.Node> nodes = new ArrayList<>(replicas.size());
@@ -842,9 +846,13 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
for (Replica replica : replicas) {
String coreNodeName = replica.getName();
if (skipList != null && skipListSet.contains(replica.getCoreUrl())) {
- log.info("check url:" + replica.getCoreUrl() + " against:" + skipListSet + " result:true");
+ if (log.isInfoEnabled()) {
+ log.info("check url:{} against:{} result:true", replica.getCoreUrl(), skipListSet);
+ }
} else if (zkShardTerms.registered(coreNodeName) && zkShardTerms.skipSendingUpdatesTo(coreNodeName)) {
- log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl());
+ if (log.isDebugEnabled()) {
+ log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl());
+ }
skippedCoreNodeNames.add(replica.getName());
} else if (!clusterState.getLiveNodes().contains(replica.getNodeName())
|| replica.getState() == Replica.State.DOWN) {
@@ -944,9 +952,9 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
"routeKey", routeKey + "!");
zkController.getOverseer().offerStateUpdate(Utils.toJSON(map));
} catch (KeeperException e) {
- log.warn("Exception while removing routing rule for route key: " + routeKey, e);
+ log.warn("Exception while removing routing rule for route key: {}", routeKey, e);
} catch (Exception e) {
- log.error("Exception while removing routing rule for route key: " + routeKey, e);
+ log.error("Exception while removing routing rule for route key: {}", routeKey, e);
} finally {
ruleExpiryLock.unlock();
}
@@ -990,7 +998,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
} else {
String fromCollection = req.getParams().get(DISTRIB_FROM_COLLECTION); // is it because of a routing rule?
if (fromCollection == null) {
- log.error("Request says it is coming from leader, but we are the leader: " + req.getParamString());
+ log.error("Request says it is coming from leader, but we are the leader: {}", req.getParamString());
SolrException solrExc = new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Request says it is coming from leader, but we are the leader");
solrExc.setMetadata("cause", "LeaderChanged");
throw solrExc;
@@ -1081,7 +1089,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
// for now we don't error - we assume if it was added locally, we
// succeeded
if (log.isWarnEnabled()) {
- log.warn("Error sending update to " + error.req.node.getBaseUrl(), error.e);
+ log.warn("Error sending update to {}", error.req.node.getBaseUrl(), error.e);
}
// Since it is not a forward request, for each fail, try to tell them to
@@ -1103,8 +1111,8 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
String cause = (error.e instanceof SolrException) ? ((SolrException)error.e).getMetadata("cause") : null;
if ("LeaderChanged".equals(cause)) {
// let's just fail this request and let the client retry? or just call processAdd again?
- log.error("On "+cloudDesc.getCoreNodeName()+", replica "+replicaUrl+
- " now thinks it is the leader! Failing the request to let the client retry! "+error.e);
+ log.error("On {}, replica {} now thinks it is the leader! Failing the request to let the client retry!"
+ , cloudDesc.getCoreNodeName(), replicaUrl, error.e);
errorsForClient.add(error);
continue;
}
@@ -1130,9 +1138,11 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
getLeaderExc = exc;
}
if (leaderCoreNodeName == null) {
- log.warn("Failed to determine if {} is still the leader for collection={} shardId={} " +
- "before putting {} into leader-initiated recovery",
- cloudDesc.getCoreNodeName(), collection, shardId, replicaUrl, getLeaderExc);
+ if (log.isWarnEnabled()) {
+ log.warn("Failed to determine if {} is still the leader for collection={} shardId={} " +
+ "before putting {} into leader-initiated recovery",
+ cloudDesc.getCoreNodeName(), collection, shardId, replicaUrl, getLeaderExc);
+ }
}
List<ZkCoreNodeProps> myReplicas = zkController.getZkStateReader().getReplicaProps(collection,
@@ -1159,23 +1169,26 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
replicasShouldBeInLowerTerms.add(coreNodeName);
} catch (Exception exc) {
Throwable setLirZnodeFailedCause = SolrException.getRootCause(exc);
- log.error("Leader failed to set replica " +
- error.req.node.getUrl() + " state to DOWN due to: " + setLirZnodeFailedCause, setLirZnodeFailedCause);
+ log.error("Leader failed to set replica {} state to DOWN due to: {}"
+ , error.req.node.getUrl(), setLirZnodeFailedCause, setLirZnodeFailedCause);
}
} else {
// not the leader anymore maybe or the error'd node is not my replica?
if (!foundErrorNodeInReplicaList) {
- log.warn("Core "+cloudDesc.getCoreNodeName()+" belonging to "+collection+" "+
- cloudDesc.getShardId()+", does not have error'd node " + stdNode.getNodeProps().getCoreUrl() + " as a replica. " +
- "No request recovery command will be sent!");
+ if (log.isWarnEnabled()) {
+ log.warn("Core {} belonging to {} {}, does not have error'd node {} as a replica. No request recovery command will be sent!"
+ , cloudDesc.getCoreNodeName(), collection, cloudDesc.getShardId(), stdNode.getNodeProps().getCoreUrl());
+ }
if (!shardId.equals(cloudDesc.getShardId())) {
// some replicas on other shard did not receive the updates (ex: during splitshard),
// exception must be notified to clients
errorsForClient.add(error);
}
} else {
- log.warn("Core " + cloudDesc.getCoreNodeName() + " is no longer the leader for " + collection + " "
- + shardId + " or we tried to put ourself into LIR, no request recovery command will be sent!");
+ if (log.isWarnEnabled()) {
+ log.warn("Core {} is no longer the leader for {} {} or we tried to put ourself into LIR, no request recovery command will be sent!"
+ , cloudDesc.getCoreNodeName(), collection, shardId);
+ }
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessor.java
index f822e10d707..8e78a551918 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessor.java
@@ -408,7 +408,7 @@ public class DocBasedVersionConstraintsProcessor extends UpdateRequestProcessor
private static void logOverlyFailedRetries(int i, UpdateCommand cmd) {
// Log a warning every 256 retries.... even a few retries should normally be very unusual.
if ((i&0xff) == 0xff) {
- log.warn("Unusual number of optimistic concurrency retries: retries=" + i + " cmd=" + cmd);
+ log.warn("Unusual number of optimistic concurrency retries: retries={} cmd={}", i, cmd);
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
index b2200d3031b..73be1ea9eb8 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java
@@ -203,7 +203,9 @@ public class DocBasedVersionConstraintsProcessorFactory extends UpdateRequestPro
userVersionField.getType().getValueSource(userVersionField, null);
} catch (Exception e) {
useFieldCache = false;
- log.warn("Can't use fieldcache/valuesource: " + e.getMessage());
+ if (log.isWarnEnabled()) {
+ log.warn("Can't use fieldcache/valuesource: {}", e.getMessage());
+ }
}
}
}
@@ -228,10 +230,12 @@ public class DocBasedVersionConstraintsProcessorFactory extends UpdateRequestPro
versionFields.forEach(field -> requiredFieldNames.remove(field));
}
if (!requiredFieldNames.isEmpty()) {
- log.warn("The schema \"{}\" has required fields that aren't added in the tombstone."
- + " This can cause deletes to fail if those aren't being added in some other way. Required Fields={}",
- schema.getSchemaName(),
- requiredFieldNames);
+ if (log.isWarnEnabled()) {
+ log.warn("The schema '{}' has required fields that aren't added in the tombstone."
+ + " This can cause deletes to fail if those aren't being added in some other way. Required Fields={}",
+ schema.getSchemaName(),
+ requiredFieldNames);
+ }
return false;
}
return true;
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
index 46779fdffe2..5305fe1ca94 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
@@ -403,8 +403,8 @@ public final class DocExpirationUpdateProcessorFactory
UpdateRequestProcessorChain chain = core.getUpdateProcessingChain(deleteChainName);
UpdateRequestProcessor proc = chain.createProcessor(req, rsp);
if (null == proc) {
- log.warn("No active processors, skipping automatic deletion " +
- "of expired docs using chain: {}", deleteChainName);
+ log.warn("No active processors, skipping automatic deletion of expired docs using chain: {}"
+ , deleteChainName);
return;
}
try {
@@ -431,11 +431,11 @@ public final class DocExpirationUpdateProcessorFactory
log.info("Finished periodic deletion of expired docs");
} catch (IOException ioe) {
- log.error("IOException in periodic deletion of expired docs: " +
+ log.error("IOException in periodic deletion of expired docs: {}",
ioe.getMessage(), ioe);
// DO NOT RETHROW: ScheduledExecutor will suppress subsequent executions
} catch (RuntimeException re) {
- log.error("Runtime error in periodic deletion of expired docs: " +
+ log.error("Runtime error in periodic deletion of expired docs: {}",
re.getMessage(), re);
// DO NOT RETHROW: ScheduledExecutor will suppress subsequent executions
} finally {
@@ -500,7 +500,7 @@ public final class DocExpirationUpdateProcessorFactory
if (previouslyInChargeOfDeletes && ! inChargeOfDeletesRightNow) {
// don't spam the logs constantly, just log when we know that we're not the guy
// (the first time -- or anytime we were, but no longer are)
- log.info("Not currently in charge of periodic deletes for this collection, " +
+ log.info("Not currently in charge of periodic deletes for this collection, {}",
"will not trigger delete or log again until this changes");
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/FieldValueMutatingUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/FieldValueMutatingUpdateProcessor.java
index b08ed9b7b09..8876b876b98 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/FieldValueMutatingUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/FieldValueMutatingUpdateProcessor.java
@@ -71,12 +71,16 @@ public abstract class FieldValueMutatingUpdateProcessor
final Object destVal = mutateValue(srcVal);
if (DELETE_VALUE_SINGLETON == destVal) {
/* NOOP */
- log.debug("removing value from field '{}': {}",
- src.getName(), srcVal);
+ if (log.isDebugEnabled()) {
+ log.debug("removing value from field '{}': {}",
+ src.getName(), srcVal);
+ }
} else {
if (destVal != srcVal) {
- log.debug("replace value from field '{}': {} with {}",
- new Object[] { src.getName(), srcVal, destVal });
+ if (log.isDebugEnabled()) {
+ log.debug("replace value from field '{}': {} with {}",
+ new Object[]{src.getName(), srcVal, destVal});
+ }
}
result.addValue(destVal);
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
index a66881652cb..a8ae4825779 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
@@ -97,7 +97,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE {} {}", cmd, req);
+ }
// call delegate first so we can log things like the version that get set later
if (next != null) next.processAdd(cmd);
@@ -120,7 +122,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
@Override
public void processDelete( DeleteUpdateCommand cmd ) throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE {} {}", cmd, req);
+ }
if (next != null) next.processDelete(cmd);
if (cmd.isDeleteById()) {
@@ -148,7 +152,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
@Override
public void processMergeIndexes(MergeIndexesCommand cmd) throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE {} {}", cmd, req);
+ }
if (next != null) next.processMergeIndexes(cmd);
toLog.add("mergeIndexes", cmd.toString());
@@ -156,7 +162,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
@Override
public void processCommit( CommitUpdateCommand cmd ) throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE {} {}", cmd, req);
+ }
if (next != null) next.processCommit(cmd);
@@ -169,7 +177,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
*/
@Override
public void processRollback( RollbackUpdateCommand cmd ) throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE {}", cmd, req);
+ }
if (next != null) next.processRollback(cmd);
toLog.add("rollback", "");
@@ -178,7 +188,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
@Override
public void finish() throws IOException {
- if (logDebug) { log.debug("PRE_UPDATE FINISH " + req); }
+ if (logDebug) {
+ log.debug("PRE_UPDATE FINISH {}", req);
+ }
if (next != null) next.finish();
// LOG A SUMMARY WHEN ALL DONE (INFO LEVEL)
@@ -190,7 +202,9 @@ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory imp
if (log.isWarnEnabled() && slowUpdateThresholdMillis >= 0) {
final long elapsed = (long) req.getRequestTimer().getTime();
if (elapsed >= slowUpdateThresholdMillis) {
- log.warn("slow: " + getLogStringAndClearRspToLog());
+ if (log.isWarnEnabled()) {
+ log.warn("slow: {}", getLogStringAndClearRspToLog());
+ }
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
index 9d53c63875e..2d28e14ed6f 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
@@ -148,8 +148,10 @@ public class ParseDateFieldUpdateProcessorFactory extends FieldMutatingUpdatePro
try {
return Date.from(parseInstant(parser, srcStringVal, parsePosition));
} catch (DateTimeParseException e) {
- log.debug("value '{}' is not parseable with format '{}'",
- new Object[] { srcStringVal, format.getKey() });
+ if (log.isDebugEnabled()) {
+ log.debug("value '{}' is not parseable with format '{}'",
+ new Object[]{srcStringVal, format.getKey()});
+ }
}
}
log.debug("value '{}' was not parsed by any configured format, thus was not mutated", srcStringVal);
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseDoubleFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseDoubleFieldUpdateProcessorFactory.java
index 3190960f4ce..ad7eabb773e 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseDoubleFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseDoubleFieldUpdateProcessorFactory.java
@@ -102,8 +102,10 @@ public class ParseDoubleFieldUpdateProcessorFactory extends ParseNumericFieldUpd
ParsePosition pos = new ParsePosition(0);
Number number = numberFormat.get().parse(stringVal, pos);
if (pos.getIndex() != stringVal.length()) {
- log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
- new Object[] { srcVal, stringVal.substring(pos.getIndex())});
+ if (log.isDebugEnabled()) {
+ log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
+ new Object[]{srcVal, stringVal.substring(pos.getIndex())});
+ }
return SKIP_FIELD_VALUE_LIST_SINGLETON;
}
return number.doubleValue();
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseFloatFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseFloatFieldUpdateProcessorFactory.java
index 2567d32ba1e..732d3148ca3 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseFloatFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseFloatFieldUpdateProcessorFactory.java
@@ -103,8 +103,10 @@ public class ParseFloatFieldUpdateProcessorFactory extends ParseNumericFieldUpda
ParsePosition pos = new ParsePosition(0);
Number number = numberFormat.get().parse(stringVal, pos);
if (pos.getIndex() != stringVal.length()) {
- log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
- new Object[] { srcVal, stringVal.substring(pos.getIndex())});
+ if (log.isDebugEnabled()) {
+ log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
+ new Object[]{srcVal, stringVal.substring(pos.getIndex())});
+ }
return SKIP_FIELD_VALUE_LIST_SINGLETON;
}
return number.floatValue();
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java
index d3b12ec3b71..3cc7dc17baf 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java
@@ -98,8 +98,10 @@ public class ParseIntFieldUpdateProcessorFactory extends ParseNumericFieldUpdate
ParsePosition pos = new ParsePosition(0);
Number number = numberFormat.get().parse(stringVal, pos);
if (pos.getIndex() != stringVal.length()) {
- log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
- new Object[] { srcVal, stringVal.substring(pos.getIndex())});
+ if (log.isDebugEnabled()) {
+ log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
+ new Object[]{srcVal, stringVal.substring(pos.getIndex())});
+ }
return SKIP_FIELD_VALUE_LIST_SINGLETON;
}
int intValue = number.intValue();
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseLongFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseLongFieldUpdateProcessorFactory.java
index 95e063bfdce..b93a28fc942 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseLongFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseLongFieldUpdateProcessorFactory.java
@@ -98,8 +98,10 @@ public class ParseLongFieldUpdateProcessorFactory extends ParseNumericFieldUpdat
ParsePosition pos = new ParsePosition(0);
Number number = numberFormat.get().parse(stringVal, pos);
if (pos.getIndex() != stringVal.length()) {
- log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
- new Object[] { srcVal, stringVal.substring(pos.getIndex())});
+ if (log.isDebugEnabled()) {
+ log.debug("value '{}' is not parseable, thus not mutated; unparsed chars: '{}'",
+ new Object[]{srcVal, stringVal.substring(pos.getIndex())});
+ }
return SKIP_FIELD_VALUE_LIST_SINGLETON;
}
return number.longValue();
diff --git a/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java
index 66b79451717..9accd400c16 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java
@@ -164,7 +164,9 @@ class PreAnalyzedUpdateProcessor extends FieldMutatingUpdateProcessor {
if (pre != null) {
res.addValue(pre);
} else { // restore the original value
- log.warn("Could not parse field {} - using original value as is: {}", src.getName(), o);
+ if (log.isWarnEnabled()) {
+ log.warn("Could not parse field {} - using original value as is: {}", src.getName(), o);
+ }
res.addValue(o);
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/RegexpBoostProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/RegexpBoostProcessor.java
index 3f41a940ebd..dfa9032f30a 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/RegexpBoostProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/RegexpBoostProcessor.java
@@ -105,7 +105,7 @@ public class RegexpBoostProcessor extends UpdateRequestProcessor {
this.boostEntries = cachedBoostEntries;
}
} catch (IOException ioe) {
- log.warn("IOException while initializing boost entries from file " + this.boostFilename, ioe);
+ log.warn("IOException while initializing boost entries from file {}", this.boostFilename, ioe);
}
}
@@ -140,9 +140,9 @@ public class RegexpBoostProcessor extends UpdateRequestProcessor {
String regexp = fields[0];
String boost = fields[1];
newBoostEntries.add(new BoostEntry(Pattern.compile(regexp), Double.parseDouble(boost)));
- log.debug("Read regexp " + regexp + " with boost " + boost);
+ log.debug("Read regexp {} with boost {}", regexp, boost);
} else {
- log.warn("Malformed config input line: " + line + " (expected 2 fields, got " + fields.length + " fields). Skipping entry.");
+ log.warn("Malformed config input line: {} (expected 2 fields, got {} fields). Skipping entry.", line, fields.length);
continue;
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
index abcd0aa571c..3ff5d03dbf3 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
@@ -255,7 +255,9 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
NamedList<String> remoteErrMetadata = remoteErr.getMetadata();
if (null == remoteErrMetadata) {
- log.warn("remote error has no metadata to aggregate: " + remoteErr.getMessage(), remoteErr);
+ if (log.isWarnEnabled()) {
+ log.warn("remote error has no metadata to aggregate: {} {}", remoteErr.getMessage(), remoteErr);
+ }
continue;
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
index a99b7cb7dc6..4444c92ecc1 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
@@ -125,9 +125,11 @@ public class URLClassifyProcessor extends UpdateRequestProcessor {
if (canonicalUrlFieldname != null) {
document.setField(canonicalUrlFieldname, getCanonicalUrl(normalizedURL));
}
- log.debug(document.toString());
+ log.debug("{}", document);
} catch (MalformedURLException | URISyntaxException e) {
- log.warn("cannot get the normalized url for \"" + url + "\" due to " + e.getMessage());
+ if (log.isWarnEnabled()) {
+ log.warn("cannot get the normalized url for '{}' due to {}", url, e.getMessage());
+ }
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
index a912e2ab0f0..cdb304c9a9c 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
@@ -126,7 +126,7 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
(null != info.name ? info.name : "") + "\"" +
(info.isDefault() ? " (default)" : "");
- log.debug("creating " + infomsg);
+ log.debug("creating {}", infomsg);
// wrap in an ArrayList so we know we know we can do fast index lookups
// and that add(int,Object) is supported
@@ -162,7 +162,7 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
distrib.init(new NamedList());
list.add(runIndex, distrib);
- log.debug("inserting DistributedUpdateProcessorFactory into " + infomsg);
+ log.debug("inserting DistributedUpdateProcessorFactory into {}", infomsg);
}
chain = list;
@@ -268,7 +268,9 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
if (log.isDebugEnabled()) {
ArrayList<String> names = new ArrayList<>(urps.size());
for (UpdateRequestProcessorFactory urp : urps) names.add(urp.getClass().getSimpleName());
- log.debug("New dynamic chain constructed : " + StrUtils.join(names, '>'));
+ if (log.isDebugEnabled()) {
+ log.debug("New dynamic chain constructed : {}", StrUtils.join(names, '>'));
+ }
}
return result;
}