You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2023/08/23 11:48:32 UTC
[solr] branch main updated: Cleaning up old code to prevent warnings (#1834)
This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 473cea28b55 Cleaning up old code to prevent warnings (#1834)
473cea28b55 is described below
commit 473cea28b55dcf03fb2338399af321f425c90002
Author: Renato Haeberli <re...@onnet.ch>
AuthorDate: Wed Aug 23 13:48:27 2023 +0200
Cleaning up old code to prevent warnings (#1834)
---------
Co-authored-by: Renato Haeberli <>
Co-authored-by: Eric Pugh <ep...@opensourceconnections.com>
---
.../src/java/org/apache/solr/cli/AssertTool.java | 3 ---
.../java/org/apache/solr/cli/SimplePostTool.java | 31 +++++++++++-----------
.../core/src/java/org/apache/solr/cli/SolrCLI.java | 11 +++-----
.../src/java/org/apache/solr/cli/StatusTool.java | 5 +---
4 files changed, 19 insertions(+), 31 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cli/AssertTool.java b/solr/core/src/java/org/apache/solr/cli/AssertTool.java
index 9ece33ccb8d..44b4dce1250 100644
--- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java
@@ -30,7 +30,6 @@ import org.apache.commons.cli.Option;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.HealthCheckRequest;
-import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -231,8 +230,6 @@ public class AssertTool extends ToolBase {
NamedList<Object> response = solrClient.request(new HealthCheckRequest());
Integer statusCode = (Integer) response.findRecursive("responseHeader", "status");
SolrCLI.checkCodeForAuthError(statusCode);
- } catch (SolrException se) {
- throw se;
} catch (IOException | SolrServerException e) {
log.debug("Opening connection to {} failed, Solr does not seem to be running", url, e);
return 0;
diff --git a/solr/core/src/java/org/apache/solr/cli/SimplePostTool.java b/solr/core/src/java/org/apache/solr/cli/SimplePostTool.java
index d15650e1636..6def73ad789 100644
--- a/solr/core/src/java/org/apache/solr/cli/SimplePostTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/SimplePostTool.java
@@ -519,14 +519,7 @@ public class SimplePostTool {
int filesPosted = 0;
for (int j = startIndexInArgs; j < args.length; j++) {
File srcFile = new File(args[j]);
- boolean isValidPath = checkIsValidPath(srcFile);
- if (isValidPath && srcFile.isDirectory() && srcFile.canRead()) {
- filesPosted += postDirectory(srcFile, out, type);
- } else if (isValidPath && srcFile.isFile() && srcFile.canRead()) {
- filesPosted += postFiles(new File[] {srcFile}, out, type);
- } else {
- filesPosted += handleGlob(srcFile, out, type);
- }
+ filesPosted = getFilesPosted(out, type, srcFile);
}
return filesPosted;
}
@@ -544,14 +537,20 @@ public class SimplePostTool {
reset();
int filesPosted = 0;
for (File srcFile : files) {
- boolean isValidPath = checkIsValidPath(srcFile);
- if (isValidPath && srcFile.isDirectory() && srcFile.canRead()) {
- filesPosted += postDirectory(srcFile, out, type);
- } else if (isValidPath && srcFile.isFile() && srcFile.canRead()) {
- filesPosted += postFiles(new File[] {srcFile}, out, type);
- } else {
- filesPosted += handleGlob(srcFile, out, type);
- }
+ filesPosted = getFilesPosted(out, type, srcFile);
+ }
+ return filesPosted;
+ }
+
+ private int getFilesPosted(final OutputStream out, final String type, final File srcFile) {
+ int filesPosted = 0;
+ boolean isValidPath = checkIsValidPath(srcFile);
+ if (isValidPath && srcFile.isDirectory() && srcFile.canRead()) {
+ filesPosted += postDirectory(srcFile, out, type);
+ } else if (isValidPath && srcFile.isFile() && srcFile.canRead()) {
+ filesPosted += postFiles(new File[] {srcFile}, out, type);
+ } else {
+ filesPosted += handleGlob(srcFile, out, type);
}
return filesPosted;
}
diff --git a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java b/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
index 0459892eeea..d7a424f6215 100755
--- a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
@@ -27,7 +27,6 @@ import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.net.ConnectException;
import java.net.SocketException;
import java.net.URL;
import java.util.ArrayList;
@@ -378,11 +377,7 @@ public class SolrCLI implements CLIO {
*/
public static boolean checkCommunicationError(Exception exc) {
Throwable rootCause = SolrException.getRootCause(exc);
- boolean wasCommError =
- (rootCause instanceof ConnectException
- || rootCause instanceof SolrServerException
- || rootCause instanceof SocketException);
- return wasCommError;
+ return (rootCause instanceof SolrServerException || rootCause instanceof SocketException);
}
public static void checkCodeForAuthError(int code) {
@@ -600,8 +595,8 @@ public class SolrCLI implements CLIO {
}
NamedList<Object> existsCheckResult =
CoreAdminRequest.getStatus(coreName, solrClient).getResponse();
- NamedList<Object> status = (NamedList) existsCheckResult.get("status");
- NamedList<Object> coreStatus = (NamedList) status.get(coreName);
+ NamedList<Object> status = (NamedList<Object>) existsCheckResult.get("status");
+ NamedList<Object> coreStatus = (NamedList<Object>) status.get(coreName);
Map<String, Object> failureStatus =
(Map<String, Object>) existsCheckResult.get("initFailures");
String errorMsg = (String) failureStatus.get(coreName);
diff --git a/solr/core/src/java/org/apache/solr/cli/StatusTool.java b/solr/core/src/java/org/apache/solr/cli/StatusTool.java
index 546dc742f3d..3758a60b3fe 100644
--- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
@@ -130,8 +129,6 @@ public class StatusTool extends ToolBase {
while (System.nanoTime() < timeout) {
try {
return getStatus(solrUrl);
- } catch (SSLPeerUnverifiedException exc) {
- throw exc;
} catch (Exception exc) {
if (SolrCLI.exceptionIsAuthRelated(exc)) {
throw exc;
@@ -204,7 +201,7 @@ public class StatusTool extends ToolBase {
cloudStatus.put("liveNodes", String.valueOf(liveNodes.size()));
Map<String, Object> collections =
- ((NamedList) json.findRecursive("cluster", "collections")).asMap();
+ ((NamedList<Object>) json.findRecursive("cluster", "collections")).asMap();
cloudStatus.put("collections", String.valueOf(collections.size()));
return cloudStatus;