Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6273: Fixed a null check, some typos and a few compiler warnings

Shalin Shekhar Mangar5beea1098eef
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrReplicator.java b/solr/core/src/java/org/apache/solr/handler/CdcrReplicator.java
index 9b1e92bd1eb..659c899d43f 100644
--- a/solr/core/src/java/org/apache/solr/handler/CdcrReplicator.java
+++ b/solr/core/src/java/org/apache/solr/handler/CdcrReplicator.java
@@ -66,7 +66,7 @@ public class CdcrReplicator implements Runnable {
// Add the param to indicate the {@link CdcrUpdateProcessor} to keep the provided version number
req.setParam(CdcrUpdateProcessor.CDCR_UPDATE, "");
- // Start the benchmakr timer
+ // Start the benchmark timer
state.getBenchmarkTimer().start();
long counter = 0;
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorScheduler.java b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorScheduler.java
index 0f11830fa84..3afcb9c40b4 100644
--- a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorScheduler.java
+++ b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorScheduler.java
@@ -64,7 +64,6 @@ class CdcrReplicatorScheduler {
void start() {
if (!isStarted) {
scheduler = Executors.newSingleThreadScheduledExecutor(new DefaultSolrThreadFactory("cdcr-scheduler"));
- //replicatorsPool = Executors.newFixedThreadPool(poolSize, new DefaultSolrThreadFactory("cdcr-replicator"));
replicatorsPool = ExecutorUtil.newMDCAwareFixedThreadPool(poolSize, new DefaultSolrThreadFactory("cdcr-replicator"));
// the scheduler thread is executed every second and submits one replication task
@@ -75,7 +74,7 @@ class CdcrReplicatorScheduler {
public void run() {
int nCandidates = statesQueue.size();
for (int i = 0; i < nCandidates; i++) {
- // a thread that pool one state from the queue, execute the replication task, and push back
+ // a thread that poll one state from the queue, execute the replication task, and push back
// the state in the queue when the task is completed
replicatorsPool.execute(new Runnable() {
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorState.java b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorState.java
index 3b64b163b91..c5eaf9275b7 100644
--- a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorState.java
+++ b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorState.java
@@ -147,7 +147,7 @@ class CdcrReplicatorState {
// Shift back to the right by 20 bits the version number - See VersionInfo#getNewClock
return DateFormatUtil.formatExternal(new Date(logReader.getLastVersion() >> 20));
}
- return new String();
+ return "";
}
/**
@@ -201,7 +201,6 @@ class CdcrReplicatorState {
}
default:
- return;
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/CdcrRequestHandler.java
index 408748688e5..60921ad2465 100644
--- a/solr/core/src/java/org/apache/solr/handler/CdcrRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/CdcrRequestHandler.java
@@ -126,10 +126,10 @@ public class CdcrRequestHandler extends RequestHandlerBase implements SolrCoreAw
replicasConfiguration = new HashMap<>();
List replicas = args.getAll(CdcrParams.REPLICA_PARAM);
for (Object replica : replicas) {
- if (replicas != null && replica instanceof NamedList) {
+ if (replica != null && replica instanceof NamedList) {
SolrParams params = SolrParams.toSolrParams((NamedList) replica);
if (!replicasConfiguration.containsKey(params.get(CdcrParams.SOURCE_COLLECTION_PARAM))) {
- replicasConfiguration.put(params.get(CdcrParams.SOURCE_COLLECTION_PARAM), new ArrayList<SolrParams>());
+ replicasConfiguration.put(params.get(CdcrParams.SOURCE_COLLECTION_PARAM), new ArrayList<>());
}
replicasConfiguration.get(params.get(CdcrParams.SOURCE_COLLECTION_PARAM)).add(params);
}
@@ -591,8 +591,7 @@ public class CdcrRequestHandler extends RequestHandlerBase implements SolrCoreAw
@Override
public Long call() throws Exception {
- HttpSolrClient server = new HttpSolrClient(baseUrl);
- try {
+ try (HttpSolrClient server = new HttpSolrClient(baseUrl)) {
server.setConnectionTimeout(15000);
server.setSoTimeout(60000);
@@ -604,8 +603,6 @@ public class CdcrRequestHandler extends RequestHandlerBase implements SolrCoreAw
NamedList response = server.request(request);
return (Long) response.get(CdcrParams.CHECKPOINT);
- } finally {
- server.close();
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrStateManager.java b/solr/core/src/java/org/apache/solr/handler/CdcrStateManager.java
index 035f6fe00c8..0d0ed02ba24 100644
--- a/solr/core/src/java/org/apache/solr/handler/CdcrStateManager.java
+++ b/solr/core/src/java/org/apache/solr/handler/CdcrStateManager.java
@@ -38,9 +38,9 @@ abstract class CdcrStateManager {
}
}
- static interface CdcrStateObserver {
+ interface CdcrStateObserver {
- public void stateUpdate();
+ void stateUpdate();
}