Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16736: Replace commons-lang3 usages with Java (#1498)

Kevin Risden70b6e4f6952c
diff --git a/gradle/validation/forbidden-apis/org.apache.commons.commons-lang3.all.txt b/gradle/validation/forbidden-apis/org.apache.commons.commons-lang3.all.txt
new file mode 100644
index 00000000000..fb37821241e
--- /dev/null
+++ b/gradle/validation/forbidden-apis/org.apache.commons.commons-lang3.all.txt
@@ -0,0 +1,84 @@
+@defaultMessage Build compareTo manually
+org.apache.commons.lang3.builder.CompareToBuilder
+
+@defaultMessage Use Objects.hash instead
+org.apache.commons.lang3.builder.HashCodeBuilder
+
+@defaultMessage Use Objects.equals instead
+org.apache.commons.lang3.builder.EqualsBuilder
+
+@defaultMessage Use manual String builder
+org.apache.commons.lang3.builder.ToStringBuilder
+
+@defaultMessage Expand array and add element
+org.apache.commons.lang3.ArrayUtils#add(**)
+
+@defaultMessage Use Array.getLength instead
+org.apache.commons.lang3.ArrayUtils#isEmpty(**)
+org.apache.commons.lang3.ArrayUtils#isNotEmpty(**)
+
+@defaultMessage Use Arrays.stream(primitive[]).boxed().toArray() instead
+org.apache.commons.lang3.ArrayUtils.toObject(**)
+
+@defaultMessage Use Arrays.stream(Integer[]).mapToInt(v -> v).toArray() instead
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Integer[])
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Integer[],int)
+
+@defaultMessage Use Arrays.stream(Long[]).mapToLong(v -> v).toArray() instead
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Long[])
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Long[],long)
+
+@defaultMessage Use Arrays.stream(Double[]).mapToDouble(v -> v).toArray() instead
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Double[])
+org.apache.commons.lang3.ArrayUtils#toPrimitive(java.lang.Double[],double)
+
+@defaultMessage Use loop to convert from array to primitive
+org.apache.commons.lang3.ArrayUtils#toPrimitive(**)
+
+@defaultMessage Use org.apache.solr.util.LocaleUtils
+org.apache.commons.lang3.LocaleUtils
+
+@defaultMessage Use com.carrotsearch.randomizedtesting.generators.RandomStrings instead
+org.apache.commons.lang3.RandomStringUtils
+
+@defaultMessage Use String contains method instead
+org.apache.commons.lang3.StringUtils#contains(**)
+
+@defaultMessage Use String endsWith method instead
+org.apache.commons.lang3.StringUtils#endsWith(**)
+
+@defaultMessage Use Objects.equals instead
+org.apache.commons.lang3.StringUtils#equals(**)
+
+@defaultMessage Use String equalsIgnoreCase instead
+org.apache.commons.lang3.StringUtils#equalsIgnoreCase(**)
+
+@defaultMessage Use StrUtils.isBlank instead
+org.apache.commons.lang3.StringUtils#isBlank(**)
+
+@defaultMessage Use StrUtils.isNotBlank instead
+org.apache.commons.lang3.StringUtils#isNotBlank(**)
+
+@defaultMessage Use StrUtils.isNullOrEmpty instead
+org.apache.commons.lang3.StringUtils#isEmpty(**)
+
+@defaultMessage Use StrUtils.isNotNullOrEmpty instead
+org.apache.commons.lang3.StringUtils#isNotEmpty(**)
+
+@defaultMessage Use String.join or Collectors.joining instead
+org.apache.commons.lang3.StringUtils#join(**)
+
+@defaultMessage Use String repeat method instead
+org.apache.commons.lang3.StringUtils#repeat(**)
+
+@defaultMessage Use String split method instead
+org.apache.commons.lang3.StringUtils#split(**)
+
+@defaultMessage Use String startsWith method instead
+org.apache.commons.lang3.StringUtils#startsWith(**)
+
+@defaultMessage Use org.apache.lucene.util.Constants instead
+org.apache.commons.lang3.SystemUtils
+
+@defaultMessage Use JDK classes where possible
+org.apache.commons.lang3.**
diff --git a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java
index 072eb246b10..7ec6ab6a919 100644
--- a/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java
+++ b/solr/core/src/java/org/apache/solr/api/AnnotatedApi.java
@@ -34,8 +34,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+import java.util.Objects;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SpecProvider;
@@ -339,14 +338,7 @@ public class AnnotatedApi extends Api implements PermissionNameProvider, Closeab
@Override
public int hashCode() {
- return new HashCodeBuilder()
- .append(command)
- .append(method)
- .append(obj)
- .append(paramsCount)
- .append(parameterClass)
- .append(isWrappedInPayloadObj)
- .toHashCode();
+ return Objects.hash(command, method, obj, paramsCount, parameterClass, isWrappedInPayloadObj);
}
@Override
@@ -356,14 +348,12 @@ public class AnnotatedApi extends Api implements PermissionNameProvider, Closeab
if (!(rhs instanceof Cmd)) return false;
final Cmd rhsCast = (Cmd) rhs;
- return new EqualsBuilder()
- .append(command, rhsCast.command)
- .append(method, rhsCast.method)
- .append(obj, rhsCast.obj)
- .append(paramsCount, rhsCast.paramsCount)
- .append(parameterClass, rhsCast.parameterClass)
- .append(isWrappedInPayloadObj, rhsCast.isWrappedInPayloadObj)
- .isEquals();
+ return Objects.equals(command, rhsCast.command)
+ && Objects.equals(method, rhsCast.method)
+ && Objects.equals(obj, rhsCast.obj)
+ && paramsCount == rhsCast.paramsCount
+ && Objects.equals(parameterClass, rhsCast.parameterClass)
+ && isWrappedInPayloadObj == rhsCast.isWrappedInPayloadObj;
}
private void checkForErrorInPayload(CommandOperation cmd) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
index d38f5fca1c4..7d013f875ec 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.util.PropertiesUtil;
import org.apache.solr.common.util.StrUtils;
@@ -157,17 +156,17 @@ public class CloudDescriptor {
if (reloadFrom == null) return;
setShardId(
- StringUtils.isEmpty(reloadFrom.getShardId()) ? getShardId() : reloadFrom.getShardId());
+ StrUtils.isNullOrEmpty(reloadFrom.getShardId()) ? getShardId() : reloadFrom.getShardId());
setCollectionName(
- StringUtils.isEmpty(reloadFrom.getCollectionName())
+ StrUtils.isNullOrEmpty(reloadFrom.getCollectionName())
? getCollectionName()
: reloadFrom.getCollectionName());
- setRoles(StringUtils.isEmpty(reloadFrom.getRoles()) ? getRoles() : reloadFrom.getRoles());
+ setRoles(StrUtils.isNullOrEmpty(reloadFrom.getRoles()) ? getRoles() : reloadFrom.getRoles());
if (reloadFrom.getNumShards() != null) {
setNumShards(reloadFrom.getNumShards());
}
setCoreNodeName(
- StringUtils.isEmpty(reloadFrom.getCoreNodeName())
+ StrUtils.isNullOrEmpty(reloadFrom.getCoreNodeName())
? getCoreNodeName()
: reloadFrom.getCoreNodeName());
setLeader(reloadFrom.isLeader);
diff --git a/solr/core/src/java/org/apache/solr/cloud/ExclusiveSliceProperty.java b/solr/core/src/java/org/apache/solr/cloud/ExclusiveSliceProperty.java
index 82639a13958..18c21e93d66 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ExclusiveSliceProperty.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ExclusiveSliceProperty.java
@@ -29,9 +29,9 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Random;
import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.overseer.ClusterStateMutator;
import org.apache.solr.cloud.overseer.CollectionMutator;
import org.apache.solr.cloud.overseer.SliceMutator;
@@ -43,6 +43,7 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionAdminParams;
+import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,14 +76,14 @@ class ExclusiveSliceProperty {
ExclusiveSliceProperty(ClusterState clusterState, ZkNodeProps message) {
this.clusterState = clusterState;
- String tmp = message.getStr(ZkStateReader.PROPERTY_PROP);
- if (!StringUtils.startsWith(tmp, CollectionAdminParams.PROPERTY_PREFIX)) {
+ String tmp = message.getStr(ZkStateReader.PROPERTY_PROP, "");
+ if (!tmp.startsWith(CollectionAdminParams.PROPERTY_PREFIX)) {
tmp = CollectionAdminParams.PROPERTY_PREFIX + tmp;
}
this.property = tmp.toLowerCase(Locale.ROOT);
collectionName = message.getStr(ZkStateReader.COLLECTION_PROP);
- if (StringUtils.isBlank(collectionName) || StringUtils.isBlank(property)) {
+ if (StrUtils.isBlank(collectionName) || StrUtils.isBlank(property)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Overseer '"
@@ -144,7 +145,7 @@ class ExclusiveSliceProperty {
boolean sliceHasProp = false;
for (Replica replica : slice.getReplicas()) {
if (onlyActiveNodes && isActive(replica) == false) {
- if (StringUtils.isNotBlank(replica.getStr(property))) {
+ if (StrUtils.isNotBlank(replica.getStr(property))) {
// Note, we won't be committing this to ZK until later.
removeProp(slice, replica.getName());
}
@@ -152,7 +153,7 @@ class ExclusiveSliceProperty {
}
allHosts.add(replica.getNodeName());
String nodeName = replica.getNodeName();
- if (StringUtils.isNotBlank(replica.getStr(property))) {
+ if (StrUtils.isNotBlank(replica.getStr(property))) {
if (sliceHasProp) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
@@ -237,7 +238,7 @@ class ExclusiveSliceProperty {
ListIterator<SliceReplica> iter = ent.getValue().listIterator();
while (iter.hasNext()) {
SliceReplica sr = iter.next();
- if (StringUtils.equals(slice, sr.slice.getName()) == false) {
+ if (Objects.equals(slice, sr.slice.getName()) == false) {
continue;
}
if (nodesHostingProp.containsKey(ent.getKey()) == false) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
index 913d4e48660..a57270c23db 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
@@ -54,7 +54,6 @@ import org.apache.solr.common.AlreadyClosedException;
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.SolrCloseable;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Slice;
@@ -68,6 +67,7 @@ import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.ObjectReleaseTracker;
import org.apache.solr.common.util.Pair;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.common.util.ZLibCompressor;
import org.apache.solr.core.CloudConfig;
@@ -746,7 +746,7 @@ public class Overseer implements SolrCloseable {
ThreadGroup tg = new ThreadGroup("Overseer state updater.");
String stateCompressionProviderClass = config.getStateCompressorClass();
Compressor compressor =
- StringUtils.isEmpty(stateCompressionProviderClass)
+ StrUtils.isNullOrEmpty(stateCompressionProviderClass)
? new ZLibCompressor()
: zkController
.getCoreContainer()
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
index 2147639d4f3..bc66611146a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
@@ -42,11 +42,11 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ClusterProperties;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkMaintenanceUtils;
import org.apache.solr.common.util.Compressor;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.ZLibCompressor;
import org.apache.solr.core.ConfigSetService;
import org.apache.solr.core.CoreContainer;
@@ -239,7 +239,7 @@ public class ZkCLI implements CLIO {
// start up a tmp zk server first
String zkServerAddress = line.getOptionValue(ZKHOST);
String solrHome = line.getOptionValue(SOLRHOME);
- if (StringUtils.isEmpty(solrHome)) {
+ if (StrUtils.isNullOrEmpty(solrHome)) {
solrHome = System.getProperty("solr.home");
}
@@ -277,7 +277,7 @@ public class ZkCLI implements CLIO {
minStateByteLenForCompression =
nodeConfig.getCloudConfig().getMinStateByteLenForCompression();
String stateCompressorClass = nodeConfig.getCloudConfig().getStateCompressorClass();
- if (!StringUtils.isEmpty(stateCompressorClass)) {
+ if (StrUtils.isNotNullOrEmpty(stateCompressorClass)) {
Class<? extends Compressor> compressionClass =
Class.forName(stateCompressorClass).asSubclass(Compressor.class);
compressor = compressionClass.getDeclaredConstructor().newInstance();
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 40ac1662714..2624252821a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -72,7 +72,6 @@ import org.apache.solr.common.AlreadyClosedException;
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DefaultConnectionStrategy;
import org.apache.solr.common.cloud.DefaultZkACLProvider;
@@ -349,21 +348,21 @@ public class ZkController implements Closeable {
String zkCredentialsInjectorClass = cloudConfig.getZkCredentialsInjectorClass();
ZkCredentialsInjector zkCredentialsInjector =
- StringUtils.isEmpty(zkCredentialsInjectorClass)
+ StrUtils.isNullOrEmpty(zkCredentialsInjectorClass)
? new DefaultZkCredentialsInjector()
: cc.getResourceLoader()
.newInstance(zkCredentialsInjectorClass, ZkCredentialsInjector.class);
String zkACLProviderClass = cloudConfig.getZkACLProviderClass();
ZkACLProvider zkACLProvider =
- StringUtils.isEmpty(zkACLProviderClass)
+ StrUtils.isNullOrEmpty(zkACLProviderClass)
? new DefaultZkACLProvider()
: cc.getResourceLoader().newInstance(zkACLProviderClass, ZkACLProvider.class);
zkACLProvider.setZkCredentialsInjector(zkCredentialsInjector);
String zkCredentialsProviderClass = cloudConfig.getZkCredentialsProviderClass();
ZkCredentialsProvider zkCredentialsProvider =
- StringUtils.isEmpty(zkCredentialsProviderClass)
+ StrUtils.isNullOrEmpty(zkCredentialsProviderClass)
? new DefaultZkCredentialsProvider()
: cc.getResourceLoader()
.newInstance(zkCredentialsProviderClass, ZkCredentialsProvider.class);
@@ -374,7 +373,7 @@ public class ZkController implements Closeable {
String stateCompressionProviderClass = cloudConfig.getStateCompressorClass();
Compressor compressor =
- StringUtils.isEmpty(stateCompressionProviderClass)
+ StrUtils.isNullOrEmpty(stateCompressionProviderClass)
? new ZLibCompressor()
: cc.getResourceLoader().newInstance(stateCompressionProviderClass, Compressor.class);
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
index cd6adf6f687..f306fc3726c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java
@@ -43,7 +43,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.cloud.ActiveReplicaWatcher;
import org.apache.solr.cloud.DistributedClusterStateUpdater;
@@ -63,6 +62,7 @@ import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.component.ShardHandler;
@@ -362,7 +362,7 @@ public class AddReplicaCmd implements CollApiCmds.CollectionApiCommand {
String coreNodeName = message.getStr(CoreAdminParams.CORE_NODE_NAME);
Replica.Type replicaType = replicaPosition.type;
- if (StringUtils.isBlank(coreName)) {
+ if (StrUtils.isBlank(coreName)) {
coreName = message.getStr(CoreAdminParams.PROPERTY_PREFIX + CoreAdminParams.NAME);
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
index 54b16f26931..8538c059d93 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollApiCmds.java
@@ -73,7 +73,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.DistributedClusterStateUpdater;
import org.apache.solr.cloud.Overseer;
import org.apache.solr.cloud.OverseerNodePrioritizer;
@@ -88,6 +87,7 @@ import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.SuppressForbidden;
import org.apache.solr.common.util.Utils;
import org.apache.solr.handler.component.ShardHandler;
@@ -343,8 +343,8 @@ public class CollApiCmds {
@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {
- if (StringUtils.isBlank(message.getStr(COLLECTION_PROP))
- || StringUtils.isBlank(message.getStr(PROPERTY_PROP))) {
+ if (StrUtils.isBlank(message.getStr(COLLECTION_PROP))
+ || StrUtils.isBlank(message.getStr(PROPERTY_PROP))) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The '"
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/InstallShardDataCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/InstallShardDataCmd.java
index f3c9cb1dec2..991577f4e46 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/InstallShardDataCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/InstallShardDataCmd.java
@@ -34,9 +34,9 @@ import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.component.ShardHandler;
import org.apache.solr.jersey.JacksonReflectMapWriter;
-import org.apache.zookeeper.common.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,12 +112,12 @@ public class InstallShardDataCmd implements CollApiCmds.CollectionApiCommand {
public String asyncId;
public void validate() {
- if (StringUtils.isBlank(collection)) {
+ if (StrUtils.isBlank(collection)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The 'Install Shard Data' API requires a valid collection name to be provided");
}
- if (StringUtils.isBlank(shard)) {
+ if (StrUtils.isBlank(shard)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The 'Install Shard Data' API requires a valid shard name to be provided");
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java
index 846ba8d67d7..ec7395bb81f 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/TimeRoutedAlias.java
@@ -17,7 +17,6 @@
package org.apache.solr.cloud.api.collections;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.solr.cloud.api.collections.RoutedAlias.CreationType.ASYNC_PREEMPTIVE;
import static org.apache.solr.cloud.api.collections.RoutedAlias.CreationType.NONE;
import static org.apache.solr.cloud.api.collections.RoutedAlias.CreationType.SYNCHRONOUS;
@@ -55,6 +54,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.RequiredSolrParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.SolrCore;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.processor.RoutedAliasUpdateProcessor;
@@ -553,7 +553,7 @@ public class TimeRoutedAlias extends RoutedAlias {
}
if (candidate.getCreationType() == NONE
- && isNotBlank(getPreemptiveCreateWindow())
+ && StrUtils.isNotBlank(getPreemptiveCreateWindow())
&& !this.preemptiveCreateOnceAlready) {
// are we getting close enough to the (as yet uncreated) next collection to warrant
// preemptive creation?
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
index 177bd81c81b..96a3a7538a7 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
@@ -32,7 +32,6 @@ import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.cloud.DistribStateManager;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.cloud.VersionedData;
@@ -52,6 +51,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.util.CollectionUtil;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.util.TestInjection;
import org.slf4j.Logger;
@@ -74,8 +74,9 @@ public class ReplicaMutator {
assert key != null;
assert value != null;
- if (StringUtils.equalsIgnoreCase(replica.getStr(key), value))
+ if (value.equalsIgnoreCase(replica.getStr(key))) {
return replica; // already the value we're going to set
+ }
Map<String, Object> replicaProps = new LinkedHashMap<>(replica.getProperties());
replicaProps.put(key, value);
@@ -132,7 +133,7 @@ public class ReplicaMutator {
String sliceName = message.getStr(ZkStateReader.SHARD_ID_PROP);
String replicaName = message.getStr(ZkStateReader.REPLICA_PROP);
String property = message.getStr(ZkStateReader.PROPERTY_PROP).toLowerCase(Locale.ROOT);
- if (!StringUtils.startsWith(property, CollectionAdminParams.PROPERTY_PREFIX)) {
+ if (!property.startsWith(CollectionAdminParams.PROPERTY_PREFIX)) {
property = CollectionAdminParams.PROPERTY_PREFIX + property;
}
property = property.toLowerCase(Locale.ROOT);
@@ -142,7 +143,7 @@ public class ReplicaMutator {
boolean isUnique = false;
if (SliceMutator.SLICE_UNIQUE_BOOLEAN_PROPERTIES.contains(property)) {
- if (StringUtils.isNotBlank(shardUnique) && Boolean.parseBoolean(shardUnique) == false) {
+ if (StrUtils.isNotBlank(shardUnique) && Boolean.parseBoolean(shardUnique) == false) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Overseer ADDREPLICAPROP for "
@@ -174,8 +175,9 @@ public class ReplicaMutator {
log.info(
"Setting property {} with value {} for collection {}", property, propVal, collectionName);
log.debug("Full message: {}", message);
- if (StringUtils.equalsIgnoreCase(replica.getStr(property), propVal))
+ if (propVal.equalsIgnoreCase(replica.getStr(property))) {
return ZkStateWriter.NO_OP; // already the value we're going to set
+ }
// OK, there's no way we won't change the cluster state now
Map<String, Replica> replicas = collection.getSlice(sliceName).getReplicasCopy();
@@ -219,7 +221,7 @@ public class ReplicaMutator {
String sliceName = message.getStr(ZkStateReader.SHARD_ID_PROP);
String replicaName = message.getStr(ZkStateReader.REPLICA_PROP);
String property = message.getStr(ZkStateReader.PROPERTY_PROP).toLowerCase(Locale.ROOT);
- if (StringUtils.startsWith(property, CollectionAdminParams.PROPERTY_PREFIX) == false) {
+ if (!property.startsWith(CollectionAdminParams.PROPERTY_PREFIX)) {
property = CollectionAdminParams.PROPERTY_PREFIX + property;
}
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
index da8c8b90877..16f2a9bbd33 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
@@ -32,8 +32,8 @@ import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.ConfigNode;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.admin.ConfigSetsHandler;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
@@ -213,7 +213,7 @@ public abstract class ConfigSetService {
for (CoreDescriptor cd : cds) {
String coreName = cd.getName();
String confName = cd.getCollectionName();
- if (StringUtils.isEmpty(confName)) confName = coreName;
+ if (StrUtils.isNullOrEmpty(confName)) confName = coreName;
Path udir = cd.getInstanceDir().resolve("conf");
log.info("Uploading directory {} with name {} for solrCore {}", udir, confName, coreName);
cc.getConfigSetService().uploadConfig(confName, udir);
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 0ae5951530f..65cc33b8539 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -59,7 +59,6 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.inject.Singleton;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.config.Lookup;
@@ -101,6 +100,7 @@ import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.ObjectCache;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.core.backup.repository.BackupRepository;
@@ -1165,7 +1165,7 @@ public class CoreContainer {
}
if (authenticationPlugin != null
- && StringUtils.isEmpty(System.getProperty("solr.jetty.https.port"))) {
+ && StrUtils.isNullOrEmpty(System.getProperty("solr.jetty.https.port"))) {
log.warn(
"Solr authentication is enabled, but SSL is off. Consider enabling SSL to protect user credentials and data with encryption.");
}
diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
index 5752c33b97e..ecfb8b55f20 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
@@ -28,11 +28,11 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.PropertiesUtil;
+import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -281,7 +281,7 @@ public class CoreDescriptor {
}
public static String checkPropertyIsNotEmpty(String value, String propName) {
- if (StringUtils.isEmpty(value)) {
+ if (StrUtils.isNullOrEmpty(value)) {
String message =
String.format(Locale.ROOT, "Cannot create core with empty %s value", propName);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, message);
diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
index 6eb0a77978c..53df61cc987 100644
--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
@@ -32,11 +32,11 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.IndexSearcher;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.logging.DeprecationLog;
import org.apache.solr.logging.LogWatcherConfig;
import org.apache.solr.servlet.SolrDispatchFilter;
@@ -202,13 +202,13 @@ public class NodeConfig {
* @return the NodeConfig
*/
public static NodeConfig loadNodeConfig(Path solrHome, Properties nodeProperties) {
- if (!StringUtils.isEmpty(System.getProperty("solr.solrxml.location"))) {
+ if (StrUtils.isNotNullOrEmpty(System.getProperty("solr.solrxml.location"))) {
log.warn(
"Solr property solr.solrxml.location is no longer supported. Will automatically load solr.xml from ZooKeeper if it exists");
}
nodeProperties = SolrXmlConfig.wrapAndSetZkHostFromSysPropIfNeeded(nodeProperties);
String zkHost = nodeProperties.getProperty(SolrXmlConfig.ZK_HOST);
- if (!StringUtils.isEmpty(zkHost)) {
+ if (StrUtils.isNotNullOrEmpty(zkHost)) {
int startUpZkTimeOut = Integer.getInteger("waitForZk", 30);
startUpZkTimeOut *= 1000;
try (SolrZkClient zkClient =
@@ -446,7 +446,7 @@ public class NodeConfig {
libDirs.add(solrInstallDir.resolve("lib").toAbsolutePath().normalize().toString());
}
- if (!StringUtils.isBlank(getSharedLibDirectory())) {
+ if (StrUtils.isNotBlank(getSharedLibDirectory())) {
List<String> sharedLibs = Arrays.asList(getSharedLibDirectory().split("\\s*,\\s*"));
libDirs.addAll(sharedLibs);
}
diff --git a/solr/core/src/java/org/apache/solr/core/NodeRoles.java b/solr/core/src/java/org/apache/solr/core/NodeRoles.java
index 36bfe3ea262..c38c92297c7 100644
--- a/solr/core/src/java/org/apache/solr/core/NodeRoles.java
+++ b/solr/core/src/java/org/apache/solr/core/NodeRoles.java
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.StrUtils;
@@ -37,7 +36,7 @@ public class NodeRoles {
public NodeRoles(String rolesString) {
Map<Role, String> roles = new EnumMap<>(Role.class);
- if (StringUtils.isEmpty(rolesString)) {
+ if (StrUtils.isNullOrEmpty(rolesString)) {
rolesString = DEFAULT_ROLES_STRING;
}
List<String> rolesList = StrUtils.splitSmart(rolesString, ',');
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index 821b6e8ba4f..723acab4709 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -37,7 +37,6 @@ import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.management.MBeanServer;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.common.ConfigNode;
import org.apache.solr.common.SolrException;
@@ -81,14 +80,14 @@ public class SolrXmlConfig {
* us.
*/
public static Properties wrapAndSetZkHostFromSysPropIfNeeded(final Properties props) {
- if (null != props && !StringUtils.isEmpty(props.getProperty(ZK_HOST))) {
+ if (null != props && StrUtils.isNotNullOrEmpty(props.getProperty(ZK_HOST))) {
// nothing to do...
return props;
}
// we always wrap if we might set a property -- never mutate the original props
final Properties results = (null == props ? new Properties() : new Properties(props));
final String sysprop = System.getProperty(ZK_HOST);
- if (!StringUtils.isEmpty(sysprop)) {
+ if (StrUtils.isNotNullOrEmpty(sysprop)) {
results.setProperty(ZK_HOST, sysprop);
}
return results;
@@ -728,7 +727,7 @@ public class SolrXmlConfig {
Set<String> props = new HashSet<>();
p.forEachChild(
it -> {
- if (it.name().equals("str") && !StringUtils.isEmpty(it.txt())) props.add(it.txt());
+ if (it.name().equals("str") && StrUtils.isNotNullOrEmpty(it.txt())) props.add(it.txt());
return Boolean.TRUE;
});
if (props.isEmpty()) {
diff --git a/solr/core/src/java/org/apache/solr/core/ZkContainer.java b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
index ba0c040e1da..23be2346099 100644
--- a/solr/core/src/java/org/apache/solr/core/ZkContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
@@ -29,7 +29,6 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.SolrZkServer;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.AlreadyClosedException;
@@ -40,6 +39,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.logging.MDCLoggingContext;
import org.apache.solr.metrics.MetricsMap;
import org.apache.solr.metrics.SolrMetricProducer;
@@ -149,7 +149,7 @@ public class ZkContainer {
cc, zookeeperHost, zkClientConnectTimeout, config, descriptorsSupplier);
if (zkRun != null) {
- if (StringUtils.isNotEmpty(System.getProperty(HTTPS_PORT_PROP))) {
+ if (StrUtils.isNotNullOrEmpty(System.getProperty(HTTPS_PORT_PROP))) {
// Embedded ZK and probably running with SSL
new ClusterProperties(zkController.getZkClient())
.setClusterProperty(ZkStateReader.URL_SCHEME, HTTPS);
diff --git a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
index 5c8dd231258..4ddc8ca90cf 100644
--- a/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
+++ b/solr/core/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -27,7 +28,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CharFilterFactory;
import org.apache.lucene.analysis.TokenFilterFactory;
@@ -435,7 +435,11 @@ public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
@Override
public int[] getPositions() {
if (cachedPositions == null) {
- cachedPositions = ArrayUtils.add(basePositions, position);
+ // add position to the end of basePositions array
+ int[] tmpPositions = new int[basePositions.length + 1];
+ System.arraycopy(basePositions, 0, tmpPositions, 0, basePositions.length);
+ tmpPositions[basePositions.length] = position;
+ cachedPositions = tmpPositions;
}
return cachedPositions;
}
@@ -457,7 +461,9 @@ public abstract class AnalysisRequestHandlerBase extends RequestHandlerBase {
reflector.reflect(TokenTrackingAttribute.class, "position", position);
// convert to Integer[] array, as only such one can be serialized by ResponseWriters
reflector.reflect(
- TokenTrackingAttribute.class, "positionHistory", ArrayUtils.toObject(getPositions()));
+ TokenTrackingAttribute.class,
+ "positionHistory",
+ Arrays.stream(getPositions()).boxed().toArray(Integer[]::new));
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/handler/CatStream.java b/solr/core/src/java/org/apache/solr/handler/CatStream.java
index 8d6a3f62de2..9c7bda7bc24 100644
--- a/solr/core/src/java/org/apache/solr/handler/CatStream.java
+++ b/solr/core/src/java/org/apache/solr/handler/CatStream.java
@@ -40,7 +40,7 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation;
import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.SolrCore;
import org.eclipse.jetty.io.RuntimeIOException;
import org.slf4j.Logger;
@@ -70,7 +70,7 @@ public class CatStream extends TupleStream implements Expressible {
}
final String filepathsWithoutSurroundingQuotes =
stripSurroundingQuotesIfTheyExist(commaDelimitedFilepaths);
- if (StringUtils.isEmpty(filepathsWithoutSurroundingQuotes)) {
+ if (StrUtils.isNullOrEmpty(filepathsWithoutSurroundingQuotes)) {
throw new IllegalArgumentException("No filepaths provided to stream");
}
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 73dd762e158..34f1395ec97 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -498,7 +498,7 @@ public class IndexFetcher {
response = getLatestVersion();
} catch (Exception e) {
final String errorMsg = e.toString();
- if (!StrUtils.isNullOrEmpty(errorMsg) && errorMsg.contains(INTERRUPT_RESPONSE_MESSAGE)) {
+ if (StrUtils.isNotNullOrEmpty(errorMsg) && errorMsg.contains(INTERRUPT_RESPONSE_MESSAGE)) {
log.warn(
"Leader at: {} is not available. Index fetch failed by interrupt. Exception: {}",
leaderUrl,
diff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index 0a31b988141..155ba9ea075 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -40,7 +40,6 @@ import org.apache.lucene.util.CharsRefBuilder;
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.api.Api;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.MoreLikeThisParams;
@@ -49,6 +48,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.CollectionUtil;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.admin.api.MoreLikeThisAPI;
import org.apache.solr.handler.component.FacetComponent;
import org.apache.solr.handler.component.ResponseBuilder;
@@ -301,10 +301,10 @@ public class MoreLikeThisHandler extends RequestHandlerBase {
String[] fl = required.getParams(MoreLikeThisParams.SIMILARITY_FIELDS);
List<String> list = new ArrayList<>();
for (String f : fl) {
- if (!StringUtils.isEmpty(f)) {
+ if (StrUtils.isNotNullOrEmpty(f)) {
String[] strings = splitList.split(f);
for (String string : strings) {
- if (!StringUtils.isEmpty(string)) {
+ if (StrUtils.isNotNullOrEmpty(string)) {
list.add(string);
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index fd7d1f2b1c7..67ae42ca38a 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -145,7 +145,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.api.Api;
import org.apache.solr.api.JerseyResource;
@@ -194,6 +193,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Pair;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.CloudConfig;
import org.apache.solr.core.CoreContainer;
@@ -632,7 +632,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
final String collectionName =
SolrIdentifierValidator.validateCollectionName((String) props.get(NAME));
final String shardsParam = (String) props.get(SHARDS_PROP);
- if (StringUtils.isNotEmpty(shardsParam)) {
+ if (StrUtils.isNotNullOrEmpty(shardsParam)) {
verifyShardsParam(shardsParam);
}
if (CollectionAdminParams.SYSTEM_COLL.equals(collectionName)) {
@@ -1335,7 +1335,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
copy(req.getParams().required(), null, COLLECTION_PROP, PROPERTY_PROP);
Boolean shardUnique = Boolean.parseBoolean(req.getParams().get(SHARD_UNIQUE));
String prop = req.getParams().get(PROPERTY_PROP).toLowerCase(Locale.ROOT);
- if (!StringUtils.startsWith(prop, PROPERTY_PREFIX)) {
+ if (!prop.startsWith(PROPERTY_PREFIX)) {
prop = PROPERTY_PREFIX + prop;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index c9420dfe1d1..e080af316bf 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -35,7 +35,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.api.Api;
import org.apache.solr.api.JerseyResource;
@@ -51,6 +50,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.handler.RequestHandlerBase;
@@ -270,7 +270,7 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
// standard core create parameters
for (Map.Entry<String, String> entry : paramToProp.entrySet()) {
String value = params.get(entry.getKey(), null);
- if (StringUtils.isNotEmpty(value)) {
+ if (StrUtils.isNotNullOrEmpty(value)) {
coreParams.put(entry.getValue(), value);
}
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
index dc557a5fa28..bf82ae38c4e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
@@ -58,7 +58,6 @@ import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@@ -67,6 +66,7 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.PropertiesUtil;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrCore;
@@ -337,11 +337,11 @@ public enum CoreAdminOperation implements CoreAdminOp {
info.add("instanceDir", desc.getInstanceDir());
// None of the following are guaranteed to be present in a not-yet-loaded core.
String tmp = desc.getDataDir();
- if (StringUtils.isNotBlank(tmp)) info.add("dataDir", tmp);
+ if (StrUtils.isNotBlank(tmp)) info.add("dataDir", tmp);
tmp = desc.getConfigName();
- if (StringUtils.isNotBlank(tmp)) info.add("config", tmp);
+ if (StrUtils.isNotBlank(tmp)) info.add("config", tmp);
tmp = desc.getSchemaName();
- if (StringUtils.isNotBlank(tmp)) info.add("schema", tmp);
+ if (StrUtils.isNotBlank(tmp)) info.add("schema", tmp);
info.add("isLoaded", "false");
}
} else {
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/RebalanceLeaders.java b/solr/core/src/java/org/apache/solr/handler/admin/RebalanceLeaders.java
index 42aa03c54ea..b8034cfed3d 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/RebalanceLeaders.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/RebalanceLeaders.java
@@ -38,7 +38,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.LeaderElector;
import org.apache.solr.cloud.OverseerTaskProcessor;
import org.apache.solr.cloud.overseer.SliceMutator;
@@ -51,6 +50,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -175,7 +175,7 @@ class RebalanceLeaders {
req.getParams().required().check(COLLECTION_PROP);
collectionName = req.getParams().get(COLLECTION_PROP);
- if (StringUtils.isBlank(collectionName)) {
+ if (StrUtils.isBlank(collectionName)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
String.format(
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/InstallShardDataAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/InstallShardDataAPI.java
index 10c50c05396..d1c1faf0f36 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/InstallShardDataAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/InstallShardDataAPI.java
@@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.admin.CollectionsHandler;
import org.apache.solr.jersey.JacksonReflectMapWriter;
@@ -44,7 +45,6 @@ import org.apache.solr.jersey.PermissionName;
import org.apache.solr.jersey.SolrJerseyResponse;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.zookeeper.common.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,7 +84,7 @@ public class InstallShardDataAPI extends AdminAPIBase {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Required request body missing");
}
- if (StringUtils.isBlank(requestBody.location)) {
+ if (StrUtils.isBlank(requestBody.location)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The Install Shard Data API requires a 'location' indicating the index data to install");
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/SplitShardAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/SplitShardAPI.java
index 0a3a8c3520f..0c75f053cae 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/SplitShardAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/SplitShardAPI.java
@@ -27,13 +27,13 @@ import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PER
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.api.Command;
import org.apache.solr.api.EndPoint;
import org.apache.solr.api.PayloadObj;
import org.apache.solr.client.solrj.request.beans.SplitShardPayload;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CommonAdminParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.admin.CollectionsHandler;
/**
@@ -64,7 +64,7 @@ public class SplitShardAPI {
v1Params.put(ACTION, CollectionParams.CollectionAction.SPLITSHARD.toLower());
v1Params.put(COLLECTION, obj.getRequest().getPathTemplateValues().get(COLLECTION));
- if (StringUtils.isNotEmpty(v2Body.splitKey)) {
+ if (StrUtils.isNotNullOrEmpty(v2Body.splitKey)) {
v1Params.put(CommonAdminParams.SPLIT_KEY, v2Body.splitKey);
}
flattenMapWithPrefix(v2Body.coreProperties, v1Params, PROPERTY_PREFIX);
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
index 30820b071f7..4f5390bc5d4 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
@@ -30,7 +30,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -69,6 +68,7 @@ import org.apache.solr.common.params.GroupParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.FieldType;
@@ -194,7 +194,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia
}
} else {
for (String fq : fqs) {
- if (StringUtils.isNotBlank(fq) && !fq.equals("*:*")) {
+ if (StrUtils.isNotBlank(fq) && !fq.equals("*:*")) {
QParser fqp = QParser.getParser(fq, req);
newFilters.add(fqp.getQuery());
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
index f78c8658ccc..88e193b6088 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
@@ -30,8 +30,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.solr.client.solrj.util.ClientUtils;
@@ -278,7 +276,7 @@ public class FacetComponent extends SearchComponent {
NamedList<Object> counts = FacetComponent.getFacetCounts(f, fdebug);
String[] pivots = params.getParams(FacetParams.FACET_PIVOT);
- if (ArrayUtils.isNotEmpty(pivots)) {
+ if (pivots != null && Array.getLength(pivots) != 0) {
PivotFacetProcessor pivotProcessor =
new PivotFacetProcessor(rb.req, rb.getResults().docSet, params, rb);
SimpleOrderedMap<List<NamedList<Object>>> v = pivotProcessor.process(pivots);
@@ -1336,7 +1334,7 @@ public class FacetComponent extends SearchComponent {
this.threadCount = threadStr != null ? Integer.parseInt(threadStr) : -1;
String excludeStr = localParams.get(CommonParams.EXCLUDE);
- if (StringUtils.isEmpty(excludeStr)) {
+ if (StrUtils.isNullOrEmpty(excludeStr)) {
this.excludeTags = Collections.emptyList();
} else {
this.excludeTags = StrUtils.splitSmart(excludeStr, ',');
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
index a814105fa59..5b227359701 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
@@ -28,7 +28,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.Http2SolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
@@ -200,8 +199,8 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory
StringBuilder sb = new StringBuilder();
NamedList<?> args = info.initArgs;
this.scheme = getParameter(args, INIT_URL_SCHEME, null, sb);
- if (StringUtils.endsWith(this.scheme, "://")) {
- this.scheme = StringUtils.removeEnd(this.scheme, "://");
+ if (this.scheme != null && this.scheme.endsWith("://")) {
+ this.scheme = this.scheme.replace("://", "");
}
String strategy =
@@ -399,8 +398,8 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory
*/
private String buildUrl(String url) {
if (!URLUtil.hasScheme(url)) {
- return StringUtils.defaultIfEmpty(scheme, DEFAULT_SCHEME) + "://" + url;
- } else if (StringUtils.isNotEmpty(scheme)) {
+ return (StrUtils.isNullOrEmpty(scheme) ? DEFAULT_SCHEME : scheme) + "://" + url;
+ } else if (StrUtils.isNotNullOrEmpty(scheme)) {
return scheme + "://" + URLUtil.removeScheme(url);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
index 83c54db956d..77b275ea4c6 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java
@@ -28,7 +28,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.RequiredSolrParams;
import org.apache.solr.common.params.ShardParams;
@@ -122,7 +121,7 @@ public class PivotFacetProcessor extends SimpleFacets {
FacetComponent.FacetContext.getFacetContext(req);
String taggedQueries = parsed.localParams.get(QUERY);
- if (StringUtils.isEmpty(taggedQueries)) {
+ if (StrUtils.isNullOrEmpty(taggedQueries)) {
facetQueries = Collections.emptyList();
} else {
List<String> localParamValue = StrUtils.splitSmart(taggedQueries, ',');
@@ -141,7 +140,7 @@ public class PivotFacetProcessor extends SimpleFacets {
}
String taggedRanges = parsed.localParams.get(RANGE);
- if (StringUtils.isEmpty(taggedRanges)) {
+ if (StrUtils.isNullOrEmpty(taggedRanges)) {
facetRanges = Collections.emptyList();
} else {
List<String> localParamValue = StrUtils.splitSmart(taggedRanges, ',');
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
index 4023ffea839..3d5b7eb28af 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
@@ -43,7 +43,6 @@ import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -568,13 +567,13 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
SolrParams params = rb.req.getParams();
String tagStr = params.get(QueryElevationParams.ELEVATE_EXCLUDE_TAGS);
- if (StringUtils.isEmpty(tagStr)) {
+ if (StrUtils.isNullOrEmpty(tagStr)) {
// the parameter that specifies tags for exclusion was not provided or had no value
return;
}
List<String> excludeTags = StrUtils.splitSmart(tagStr, ',');
- excludeTags.removeIf(s -> StringUtils.isBlank(s));
+ excludeTags.removeIf(s -> StrUtils.isBlank(s));
if (excludeTags.isEmpty()) {
// the parameter that specifies tags for exclusion was provided but the tag names were blank
return;
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index d05d3862ba7..b845e050ae3 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -60,7 +60,6 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
@@ -1360,7 +1359,7 @@ public class RealTimeGetComponent extends SearchComponent {
}
private List<Long> resolveVersionRanges(String versionsStr, UpdateLog ulog) {
- if (StringUtils.isEmpty(versionsStr)) {
+ if (StrUtils.isNullOrEmpty(versionsStr)) {
return Collections.emptyList();
}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index 636f5303849..b697eb11934 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -33,7 +33,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.search.TotalHits;
import org.apache.solr.client.solrj.SolrServerException;
@@ -46,6 +45,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CloseHook;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.PluginInfo;
@@ -628,7 +628,7 @@ public class SearchHandler extends RequestHandlerBase
// - ERRORs that may be logged during response writing
MDC.put(CommonParams.REQUEST_ID, rid);
- if (StringUtils.isBlank(rb.req.getParams().get(CommonParams.REQUEST_ID))) {
+ if (StrUtils.isBlank(rb.req.getParams().get(CommonParams.REQUEST_ID))) {
ModifiableSolrParams params = new ModifiableSolrParams(rb.req.getParams());
params.add(CommonParams.REQUEST_ID, rid); // add rid to the request so that shards see it
rb.req.setParams(params);
@@ -653,7 +653,7 @@ public class SearchHandler extends RequestHandlerBase
*/
public static String getOrGenerateRequestId(SolrQueryRequest req) {
String rid = req.getParams().get(CommonParams.REQUEST_ID);
- return StringUtils.isNotBlank(rid) ? rid : generateRid(req);
+ return StrUtils.isNotBlank(rid) ? rid : generateRid(req);
}
private static String generateRid(SolrQueryRequest req) {
diff --git a/solr/core/src/java/org/apache/solr/handler/component/StatsField.java b/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
index 35fd161f5d0..af1738bcfb5 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/StatsField.java
@@ -29,7 +29,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
@@ -255,7 +254,7 @@ public class StatsField {
SchemaField sf = null;
ValueSource vs = null;
- if (StringUtils.isBlank(parserName)) {
+ if (StrUtils.isBlank(parserName)) {
// basic request for field stats
sf = searcher.getSchema().getField(localParams.get(QueryParsing.V));
@@ -679,7 +678,7 @@ public class StatsField {
throws SolrException {
String cardinalityOpt = localParams.get(Stat.cardinality.name());
- if (StringUtils.isBlank(cardinalityOpt)) {
+ if (StrUtils.isBlank(cardinalityOpt)) {
return null;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java b/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
index 56c63f75f51..4867dd160fd 100644
--- a/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/configsets/DeleteConfigSetAPI.java
@@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.solr.api.EndPoint;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.ConfigSetParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -50,7 +50,7 @@ public class DeleteConfigSetAPI extends ConfigSetAPIBase {
permission = CONFIG_EDIT_PERM)
public void deleteConfigSet(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
final String configSetName = req.getPathTemplateValues().get("name");
- if (StringUtils.isEmpty(configSetName)) {
+ if (StrUtils.isNullOrEmpty(configSetName)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST, "No configset name provided to delete");
}
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
index 38c2d96aa65..dd98eb728e2 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java
@@ -41,7 +41,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.commons.lang3.LocaleUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
@@ -56,6 +55,7 @@ import org.apache.solr.update.processor.ParseBooleanFieldUpdateProcessorFactory;
import org.apache.solr.update.processor.ParseDateFieldUpdateProcessorFactory;
import org.apache.solr.update.processor.ParseDoubleFieldUpdateProcessorFactory;
import org.apache.solr.update.processor.ParseLongFieldUpdateProcessorFactory;
+import org.apache.solr.util.LocaleUtils;
// Just a quick hack to flush out the design, more intelligence is needed
public class DefaultSchemaSuggester implements SchemaSuggester {
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
index 41413bcd95a..5ceeb3b9b7c 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
@@ -20,7 +20,6 @@ package org.apache.solr.handler.designer;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.PUT;
-import static org.apache.solr.common.StringUtils.isEmpty;
import static org.apache.solr.common.params.CommonParams.JSON_MIME;
import static org.apache.solr.handler.admin.ConfigSetsHandler.DEFAULT_CONFIGSET_NAME;
import static org.apache.solr.schema.ManagedIndexSchemaFactory.DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME;
@@ -69,6 +68,7 @@ import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrResourceLoader;
@@ -147,7 +147,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = GET, path = "/schema-designer/info", permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void getInfo(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -183,7 +182,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = POST, path = "/schema-designer/prep", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void prepNewSchema(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -213,7 +211,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = GET, path = "/schema-designer/file", permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void getFileContents(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
final String file = getRequiredParam("file", req);
@@ -230,7 +227,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = POST, path = "/schema-designer/file", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void updateFileContents(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -315,7 +311,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = GET, path = "/schema-designer/sample", permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void getSampleValue(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
final String fieldName = getRequiredParam(FIELD_PARAM, req);
@@ -324,7 +319,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
final List<SolrInputDocument> docs = configSetHelper.getStoredSampleDocs(configSet);
String textValue = null;
- if (isEmpty(docId)) {
+ if (StrUtils.isNullOrEmpty(docId)) {
// no doc ID from client ... find the first doc with a non-empty string value for fieldName
Optional<SolrInputDocument> doc =
docs.stream()
@@ -359,7 +354,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
method = GET,
path = "/schema-designer/collectionsForConfig",
permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void listCollectionsForConfig(SolrQueryRequest req, SolrQueryResponse rsp) {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
rsp.getValues()
@@ -371,7 +365,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
// CONFIG_EDIT_PERM is required here since this endpoint is used by the UI to determine if the
// user has access to the Schema Designer UI
@EndPoint(method = GET, path = "/schema-designer/configs", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void listConfigs(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
rsp.getValues().addAll(Collections.singletonMap("configSets", listEnabledConfigs()));
}
@@ -422,7 +415,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = POST, path = "/schema-designer/add", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void addSchemaObject(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -442,7 +434,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = PUT, path = "/schema-designer/update", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void updateSchemaObject(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -451,7 +442,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
// Updated field definition is in the request body as JSON
Map<String, Object> updateField = readJsonFromRequest(req);
String name = (String) updateField.get("name");
- if (isEmpty(name)) {
+ if (StrUtils.isNullOrEmpty(name)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Invalid update request! JSON payload is missing the required name property: "
@@ -515,7 +506,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = PUT, path = "/schema-designer/publish", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void publish(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -542,7 +532,8 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
String newCollection = req.getParams().get(NEW_COLLECTION_PARAM);
- if (!isEmpty(newCollection) && zkStateReader().getClusterState().hasCollection(newCollection)) {
+ if (StrUtils.isNotNullOrEmpty(newCollection)
+ && zkStateReader().getClusterState().hasCollection(newCollection)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Collection '" + newCollection + "' already exists!");
@@ -573,7 +564,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
// create new collection
Map<Object, Throwable> errorsDuringIndexing = null;
- if (!isEmpty(newCollection)) {
+ if (StrUtils.isNotNullOrEmpty(newCollection)) {
int numShards = req.getParams().getInt("numShards", 1);
int rf = req.getParams().getInt("replicationFactor", 1);
configSetHelper.createCollection(newCollection, configSet, numShards, rf);
@@ -602,7 +593,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
Map<String, Object> response = new HashMap<>();
response.put(CONFIG_SET_PARAM, configSet);
response.put(SCHEMA_VERSION_PARAM, configSetHelper.getCurrentSchemaVersion(configSet));
- if (!isEmpty(newCollection)) {
+ if (StrUtils.isNotNullOrEmpty(newCollection)) {
response.put(NEW_COLLECTION_PARAM, newCollection);
}
@@ -612,7 +603,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = POST, path = "/schema-designer/analyze", permission = CONFIG_EDIT_PERM)
- @SuppressWarnings("unchecked")
public void analyze(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final int schemaVersion = req.getParams().getInt(SCHEMA_VERSION_PARAM, -1);
@@ -647,7 +637,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
ManagedIndexSchema schema = settings.getSchema();
String uniqueKeyFieldParam = req.getParams().get(UNIQUE_KEY_FIELD_PARAM);
- if (!isEmpty(uniqueKeyFieldParam)) {
+ if (StrUtils.isNotNullOrEmpty(uniqueKeyFieldParam)) {
String uniqueKeyField =
schema.getUniqueKeyField() != null ? schema.getUniqueKeyField().getName() : null;
if (!uniqueKeyFieldParam.equals(uniqueKeyField)) {
@@ -753,7 +743,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
}
@EndPoint(method = GET, path = "/schema-designer/query", permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void query(SolrQueryRequest req, SolrQueryResponse rsp)
throws IOException, SolrServerException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -813,7 +802,6 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
* copyFrom).
*/
@EndPoint(method = GET, path = "/schema-designer/diff", permission = CONFIG_READ_PERM)
- @SuppressWarnings("unchecked")
public void getSchemaDiff(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
@@ -1264,7 +1252,8 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
protected Map<String, Object> readJsonFromRequest(SolrQueryRequest req) throws IOException {
ContentStream stream = extractSingleContentStream(req, true);
String contentType = stream.getContentType();
- if (isEmpty(contentType) || !contentType.toLowerCase(Locale.ROOT).contains(JSON_MIME)) {
+ if (StrUtils.isNullOrEmpty(contentType)
+ || !contentType.toLowerCase(Locale.ROOT).contains(JSON_MIME)) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Expected JSON in request!");
}
final Object json;
@@ -1323,7 +1312,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
protected String getRequiredParam(final String param, final SolrQueryRequest req) {
final String paramValue = req.getParams().get(param);
- if (isEmpty(paramValue)) {
+ if (StrUtils.isNullOrEmpty(paramValue)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
param + " is a required parameter for the " + req.getPath() + " endpoint!");
diff --git a/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java b/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java
index 92c13b4178f..bebebf00945 100644
--- a/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java
+++ b/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java
@@ -24,7 +24,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrCore;
@@ -51,7 +51,7 @@ public class MDCLoggingContext {
}
public static void setTracerId(String traceId) {
- if (!StringUtils.isEmpty(traceId)) {
+ if (StrUtils.isNotNullOrEmpty(traceId)) {
MDC.put(TRACE_ID, traceId);
} else {
MDC.remove(TRACE_ID);
diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
index 4f0561abd29..c8c000826c7 100644
--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
@@ -486,7 +486,7 @@ public class PackageManager implements Closeable {
plugin.name);
Command cmd = plugin.setupCommand;
- if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && StrUtils.isNotNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
@@ -641,7 +641,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.setupCommand;
- if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && StrUtils.isNotNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
Map<String, String> overridesMap = getParameterOverrides(overrides);
@@ -764,7 +764,7 @@ public class PackageManager implements Closeable {
boolean success = true;
for (Plugin plugin : pkg.plugins) {
Command cmd = plugin.verifyCommand;
- if (plugin.verifyCommand != null && !StrUtils.isNullOrEmpty(cmd.path)) {
+ if (plugin.verifyCommand != null && StrUtils.isNotNullOrEmpty(cmd.path)) {
if ("cluster".equalsIgnoreCase(plugin.type)) {
if (!shouldDeployClusterPlugins) continue; // Plugins of type "cluster"
Map<String, String> overridesMap = getParameterOverrides(overrides);
@@ -998,7 +998,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.uninstallCommand;
- if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && StrUtils.isNotNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
@@ -1054,7 +1054,7 @@ public class PackageManager implements Closeable {
"plugin-name",
plugin.name);
Command cmd = plugin.uninstallCommand;
- if (cmd != null && !StrUtils.isNullOrEmpty(cmd.method)) {
+ if (cmd != null && StrUtils.isNotNullOrEmpty(cmd.method)) {
if ("POST".equalsIgnoreCase(cmd.method)) {
try {
String payload =
diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
index ef00715553c..9f3f393bbf0 100644
--- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
+++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java
@@ -291,7 +291,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
/** Handles the default field if null is passed */
public String getField(String fieldName) {
explicitField = fieldName;
- return !StrUtils.isNullOrEmpty(fieldName) ? fieldName : this.defaultField;
+ return StrUtils.isNotNullOrEmpty(fieldName) ? fieldName : this.defaultField;
}
/**
diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
index b6ddf0cf467..207db54e130 100644
--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
@@ -20,6 +20,7 @@ import static org.apache.solr.common.params.CommonParams.SORT;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Array;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,7 +40,6 @@ import java.util.concurrent.RunnableFuture;
import java.util.concurrent.Semaphore;
import java.util.function.Predicate;
import java.util.stream.Stream;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -786,7 +786,8 @@ public class SimpleFacets {
throws IOException {
GroupingSpecification groupingSpecification = rb.getGroupingSpec();
String[] groupFields = groupingSpecification != null ? groupingSpecification.getFields() : null;
- final String groupField = ArrayUtils.isNotEmpty(groupFields) ? groupFields[0] : null;
+ final String groupField =
+ groupFields != null && Array.getLength(groupFields) != 0 ? groupFields[0] : null;
if (groupField == null) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
diff --git a/solr/core/src/java/org/apache/solr/request/SubstringBytesRefFilter.java b/solr/core/src/java/org/apache/solr/request/SubstringBytesRefFilter.java
index 676b67e6427..a8d2a158def 100644
--- a/solr/core/src/java/org/apache/solr/request/SubstringBytesRefFilter.java
+++ b/solr/core/src/java/org/apache/solr/request/SubstringBytesRefFilter.java
@@ -17,8 +17,8 @@
package org.apache.solr.request;
import java.util.function.Predicate;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.util.BytesRef;
+import org.apache.solr.common.util.SuppressForbidden;
/**
* An implementation of {@link Predicate} which returns true if the BytesRef contains a given
@@ -39,14 +39,19 @@ public class SubstringBytesRefFilter implements Predicate<BytesRef> {
protected boolean includeString(String term) {
if (ignoreCase) {
- return StringUtils.containsIgnoreCase(term, contains);
+ return containsIgnoreCase(term, contains);
}
- return StringUtils.contains(term, contains);
+ return term.contains(contains);
}
@Override
public boolean test(BytesRef term) {
return includeString(term.utf8ToString());
}
+
+ @SuppressForbidden(reason = "Uses Stringutils.containsIgnoreCase")
+ private boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) {
+ return org.apache.commons.lang3.StringUtils.containsIgnoreCase(str, searchStr);
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java b/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
index c567fc74f37..7ae2a578dc8 100644
--- a/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
+++ b/solr/core/src/java/org/apache/solr/schema/AbstractEnumField.java
@@ -27,7 +27,6 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.apache.commons.lang3.math.NumberUtils;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.EnumFieldSource;
@@ -343,9 +342,13 @@ public abstract class AbstractEnumField extends PrimitiveFieldType {
final Integer entry = enumMapping.enumStringToIntMap.get(str);
if (entry != null) {
return new EnumFieldValue(entry, str);
- } else if (NumberUtils.isCreatable(str)) {
- final int num = Integer.parseInt(str);
- return new EnumFieldValue(num, enumMapping.enumIntToStringMap.get(num));
+ } else {
+ try {
+ final int num = Integer.parseInt(str);
+ return new EnumFieldValue(num, enumMapping.enumIntToStringMap.get(num));
+ } catch (NumberFormatException ignore) {
+ // Could not convert to Integer so fall through.
+ }
}
} else if (val instanceof Number) {
final int num = ((Number) val).intValue();
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index 4020ddafe2e..82316adf85f 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -35,7 +35,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.codecs.DocValuesProducer;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValuesType;
@@ -71,6 +70,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.GroupParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.component.QueryElevationComponent;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.request.LocalSolrQueryRequest;
@@ -176,7 +176,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
}
public static NullPolicy fromString(String nullPolicy) {
- if (StringUtils.isEmpty(nullPolicy)) {
+ if (StrUtils.isNullOrEmpty(nullPolicy)) {
return DEFAULT_POLICY;
}
switch (nullPolicy) {
@@ -266,9 +266,10 @@ public class CollapsingQParserPlugin extends QParserPlugin {
/** returns a new GroupHeadSelector based on the specified local params */
public static GroupHeadSelector build(final SolrParams localParams) {
- final String sortString = StringUtils.defaultIfBlank(localParams.get(SORT), null);
- final String max = StringUtils.defaultIfBlank(localParams.get("max"), null);
- final String min = StringUtils.defaultIfBlank(localParams.get("min"), null);
+ final String sortString =
+ StrUtils.isBlank(localParams.get(SORT)) ? null : localParams.get(SORT);
+ final String max = StrUtils.isBlank(localParams.get("max")) ? null : localParams.get("max");
+ final String min = StrUtils.isBlank(localParams.get("min")) ? null : localParams.get("min");
if (1 < numNotNull(min, max, sortString)) {
throw new SolrException(
diff --git a/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java b/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
index 28b86e6011b..06ab2d28f2b 100644
--- a/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
@@ -19,7 +19,6 @@ package org.apache.solr.search;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostQuery;
@@ -28,6 +27,7 @@ import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.DisMaxParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.parser.QueryParser;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
@@ -198,7 +198,7 @@ public class DisMaxQParser extends QParser {
parsedUserQuery = null;
String userQuery = getString();
altUserQuery = null;
- if (StringUtils.isBlank(userQuery)) {
+ if (StrUtils.isBlank(userQuery)) {
// If no query is specified, we may have an alternate
altUserQuery = getAlternateUserQuery(solrParams);
if (altUserQuery == null) return false;
diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java
index 89e45e87358..0bff78034a4 100644
--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java
@@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenFilterFactory;
import org.apache.lucene.analysis.core.StopFilterFactory;
@@ -51,6 +50,7 @@ import org.apache.solr.common.params.DisMaxParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.CollectionUtil;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.parser.QueryParser;
import org.apache.solr.parser.SolrQueryParserBase.MagicFieldName;
import org.apache.solr.request.SolrQueryRequest;
@@ -126,7 +126,7 @@ public class ExtendedDismaxQParser extends QParser {
parsedUserQuery = null;
String userQuery = getString();
altUserQuery = null;
- if (StringUtils.isBlank(userQuery)) {
+ if (StrUtils.isBlank(userQuery)) {
// If no query is specified, we may have an alternate
if (config.altQ != null) {
QParser altQParser = subQuery(config.altQ, null);
diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java
index 58de20f5097..dcc88463696 100644
--- a/solr/core/src/java/org/apache/solr/search/Grouping.java
+++ b/solr/core/src/java/org/apache/solr/search/Grouping.java
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionQuery;
@@ -696,8 +695,13 @@ public class Grouping {
}
int len = docsGathered > offset ? docsGathered - offset : 0;
- int[] docs = ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()]));
- float[] docScores = ArrayUtils.toPrimitive(scores.toArray(new Float[scores.size()]));
+ int[] docs = ids.stream().mapToInt(v -> v).toArray();
+
+ float[] docScores = new float[scores.size()];
+ // Convert scores Float to primitive docScores float
+ for (int i = 0; i < scores.size(); i++) {
+ docScores[i] = scores.get(i);
+ }
DocSlice docSlice =
new DocSlice(
offset, len, docs, docScores, getMatches(), maxScore, TotalHits.Relation.EQUAL_TO);
diff --git a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
index 6804942acd6..12204f2a196 100644
--- a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
@@ -17,12 +17,12 @@
package org.apache.solr.search;
import java.io.IOException;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryRescorer;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.SolrQueryRequest;
/*
@@ -63,7 +63,7 @@ public class ReRankQParserPlugin extends QParserPlugin {
@Override
public Query parse() throws SyntaxError {
String reRankQueryString = localParams.get(RERANK_QUERY);
- if (StringUtils.isBlank(reRankQueryString)) {
+ if (StrUtils.isBlank(reRankQueryString)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST, RERANK_QUERY + " parameter is mandatory");
}
diff --git a/solr/core/src/java/org/apache/solr/search/SwitchQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/SwitchQParserPlugin.java
index a70d7cf4823..8514484e841 100644
--- a/solr/core/src/java/org/apache/solr/search/SwitchQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/SwitchQParserPlugin.java
@@ -16,10 +16,10 @@
*/
package org.apache.solr.search;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.component.SearchHandler;
import org.apache.solr.request.SolrQueryRequest;
@@ -145,7 +145,7 @@ public class SwitchQParserPlugin extends QParserPlugin {
// clients could add their own switch options
String subQ = localParams.get(SWITCH_DEFAULT);
subQ =
- StringUtils.isBlank(val)
+ StrUtils.isBlank(val)
? localParams.get(SWITCH_CASE, subQ)
: localParams.get(SWITCH_CASE + "." + val.trim(), subQ);
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/MainEndResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/MainEndResultTransformer.java
index d3baebcac84..1e18b40a21e 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/MainEndResultTransformer.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/MainEndResultTransformer.java
@@ -16,8 +16,8 @@
*/
package org.apache.solr.search.grouping.endresulttransformer;
+import java.lang.reflect.Array;
import java.util.Map;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.grouping.GroupDocs;
@@ -40,9 +40,9 @@ public class MainEndResultTransformer implements EndResultTransformer {
Map<String, ?> result, ResponseBuilder rb, SolrDocumentSource solrDocumentSource) {
GroupingSpecification groupingSpec = rb.getGroupingSpec();
String[] entries = groupingSpec.getFields();
- if (ArrayUtils.isEmpty(entries)) {
+ if (entries == null || Array.getLength(entries) == 0) {
entries = groupingSpec.getQueries();
- if (ArrayUtils.isEmpty(entries)) {
+ if (entries == null || Array.getLength(entries) == 0) {
// group.func is not supported in distributed mode
// so when group.field or group.query is not specified return
return;
diff --git a/solr/core/src/java/org/apache/solr/search/mlt/AbstractMLTQParser.java b/solr/core/src/java/org/apache/solr/search/mlt/AbstractMLTQParser.java
index 1cd25c44dd4..356d7583f98 100644
--- a/solr/core/src/java/org/apache/solr/search/mlt/AbstractMLTQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/mlt/AbstractMLTQParser.java
@@ -29,8 +29,8 @@ import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.QParser;
@@ -108,10 +108,10 @@ abstract class AbstractMLTQParser extends QParser {
if (qf != null) {
ArrayList<String> fields = new ArrayList<>();
for (String fieldName : qf) {
- if (!StringUtils.isEmpty(fieldName)) {
+ if (StrUtils.isNotNullOrEmpty(fieldName)) {
String[] strings = splitList.split(fieldName);
for (String string : strings) {
- if (!StringUtils.isEmpty(string)) {
+ if (StrUtils.isNotNullOrEmpty(string)) {
fields.add(string);
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java b/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
index 5eb6fc1d0f4..0a0592618a1 100644
--- a/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/neural/KnnQParser.java
@@ -18,7 +18,6 @@ package org.apache.solr.search.neural;
import java.io.IOException;
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
@@ -116,7 +115,7 @@ public class KnnQParser extends QParser {
+ " The expected format is:'[f1,f2..f3]' where each element f is a float");
}
- String[] elements = StringUtils.split(value.substring(1, value.length() - 1), ',');
+ String[] elements = value.substring(1, value.length() - 1).split(",");
if (elements.length != dimension) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
diff --git a/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java b/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
index 2108d8cd5b2..cadc4fed946 100644
--- a/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/BasicAuthPlugin.java
@@ -33,7 +33,6 @@ import javax.security.auth.Subject;
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpRequest;
@@ -324,10 +323,7 @@ public class BasicAuthPlugin extends AuthenticationPlugin
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("username", username)
- .append("pwd", "*****")
- .toString();
+ return "BasicAuthPlugin [username=" + username + ",pwd=*****]";
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java b/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java
index 9281f88023c..96cd2974c21 100644
--- a/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java
@@ -34,8 +34,8 @@ import org.apache.solr.api.Api;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.SpecProvider;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.CommandOperation;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.ValidatingJsonMap;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.admin.api.ModifyMultiPluginAuthConfigAPI;
@@ -147,13 +147,13 @@ public class MultiAuthPlugin extends AuthenticationPlugin
Map<String, Object> schemeConfig = new HashMap<>(schemeMap);
String scheme = (String) schemeConfig.remove(PROPERTY_SCHEME);
- if (StringUtils.isEmpty(scheme)) {
+ if (StrUtils.isNullOrEmpty(scheme)) {
throw new SolrException(
ErrorCode.SERVER_ERROR, "'scheme' is a required attribute: " + schemeMap);
}
String clazz = (String) schemeConfig.remove("class");
- if (StringUtils.isEmpty(clazz)) {
+ if (StrUtils.isNullOrEmpty(clazz)) {
throw new SolrException(
ErrorCode.SERVER_ERROR, "'class' is a required attribute: " + schemeMap);
}
diff --git a/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java b/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java
index ecd8b9c9d4c..2506605e935 100644
--- a/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/MultiAuthRuleBasedAuthorizationPlugin.java
@@ -29,8 +29,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.lucene.util.ResourceLoader;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.CommandOperation;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
/**
@@ -81,13 +81,13 @@ public class MultiAuthRuleBasedAuthorizationPlugin extends RuleBasedAuthorizatio
Map<String, Object> schemeConfig = new HashMap<>(schemeMap);
String scheme = (String) schemeConfig.remove(MultiAuthPlugin.PROPERTY_SCHEME);
- if (StringUtils.isEmpty(scheme)) {
+ if (StrUtils.isNullOrEmpty(scheme)) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "'scheme' is a required attribute: " + schemeMap);
}
String clazz = (String) schemeConfig.remove("class");
- if (StringUtils.isEmpty(clazz)) {
+ if (StrUtils.isNullOrEmpty(clazz)) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "'class' is a required attribute: " + schemeMap);
}
diff --git a/solr/core/src/java/org/apache/solr/security/SolrNodeKeyPair.java b/solr/core/src/java/org/apache/solr/security/SolrNodeKeyPair.java
index 9eeb6b5f68e..1e93667c5d9 100644
--- a/solr/core/src/java/org/apache/solr/security/SolrNodeKeyPair.java
+++ b/solr/core/src/java/org/apache/solr/security/SolrNodeKeyPair.java
@@ -20,7 +20,7 @@ package org.apache.solr.security;
import java.io.IOException;
import java.net.URL;
import java.security.spec.InvalidKeySpecException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CloudConfig;
import org.apache.solr.util.CryptoKeys;
@@ -50,7 +50,7 @@ public class SolrNodeKeyPair {
String privateKey = config.getPkiHandlerPrivateKeyPath();
// If both properties unset, then we fall back to generating a new key pair
- if (StringUtils.isEmpty(publicKey) && StringUtils.isEmpty(privateKey)) {
+ if (StrUtils.isNullOrEmpty(publicKey) && StrUtils.isNullOrEmpty(privateKey)) {
return new CryptoKeys.RSAKeyPair();
}
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index 439cb54e49e..dbee25ec32f 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -57,7 +57,6 @@ import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.jcip.annotations.ThreadSafe;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpEntity;
@@ -996,9 +995,9 @@ public class HttpSolrCall {
String[] pairs;
if (stateVer != null && !stateVer.isEmpty() && cores.isZooKeeperAware()) {
// many have multiple collections separated by |
- pairs = StringUtils.split(stateVer, '|');
+ pairs = stateVer.split("\\|");
for (String pair : pairs) {
- String[] pcs = StringUtils.split(pair, ':');
+ String[] pcs = pair.split(":");
if (pcs.length == 2 && !pcs[0].isEmpty() && !pcs[1].isEmpty()) {
Integer status =
cores
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java
index 1f65fa727a4..15803ea2bd4 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java
@@ -18,7 +18,7 @@ package org.apache.solr.update.processor;
import static org.apache.solr.update.processor.FieldMutatingUpdateProcessor.mutator;
-import org.apache.commons.lang3.StringUtils;
+import java.util.stream.Collectors;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
@@ -79,7 +79,9 @@ public final class ConcatFieldUpdateProcessorFactory extends FieldMutatingUpdate
if (src.getValueCount() <= 1) return src;
SolrInputField result = new SolrInputField(src.getName());
- result.setValue(StringUtils.join(src.getValues(), delimiter));
+
+ result.setValue(
+ src.getValues().stream().map(String::valueOf).collect(Collectors.joining(delimiter)));
return result;
});
}
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 ac46e6b1043..f06f4a4af68 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
@@ -35,7 +35,6 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.LocaleUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
@@ -44,6 +43,7 @@ import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.DateValueFieldType;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.LocaleUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/solr/core/src/java/org/apache/solr/update/processor/ParseNumericFieldUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ParseNumericFieldUpdateProcessorFactory.java
index 84a5165f15d..dae2520bcad 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/ParseNumericFieldUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/ParseNumericFieldUpdateProcessorFactory.java
@@ -17,12 +17,12 @@
package org.apache.solr.update.processor;
import java.util.Locale;
-import org.apache.commons.lang3.LocaleUtils;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;
+import org.apache.solr.util.LocaleUtils;
/**
* Abstract base class for numeric parsing update processor factories. Subclasses can optionally
diff --git a/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java
index db642f96582..0cbb1f71b23 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/RoutedAliasUpdateProcessor.java
@@ -26,7 +26,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.api.collections.RoutedAlias;
@@ -41,6 +40,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrCore;
@@ -105,7 +105,7 @@ public class RoutedAliasUpdateProcessor extends UpdateRequestProcessor {
aliasName = collectionProperties.get(RoutedAlias.ROUTED_ALIAS_NAME_CORE_PROP);
}
// fall back on core properties (legacy)
- if (StringUtils.isBlank(aliasName)) {
+ if (StrUtils.isBlank(aliasName)) {
aliasName = coreDescriptor.getCoreProperty(RoutedAlias.ROUTED_ALIAS_NAME_CORE_PROP, null);
}
final DistribPhase shardDistribPhase =
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UUIDUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/UUIDUpdateProcessorFactory.java
index 16d7963ef1a..f62b6127e04 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UUIDUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UUIDUpdateProcessorFactory.java
@@ -18,8 +18,8 @@ package org.apache.solr.update.processor;
import java.util.Locale;
import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.SchemaField;
@@ -76,11 +76,11 @@ public class UUIDUpdateProcessorFactory extends UpdateRequestProcessorFactory {
String fieldName = this.fieldName;
String fname = req.getParams().get(PREFIX_PARAM + FIELD_PARAM);
- if (!StringUtils.isEmpty(fname)) {
+ if (StrUtils.isNotNullOrEmpty(fname)) {
fieldName = fname;
}
- if (StringUtils.isEmpty(fieldName)) {
+ if (StrUtils.isNullOrEmpty(fieldName)) {
SchemaField schemaField = req.getSchema().getUniqueKeyField();
fieldName = schemaField.getName();
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/StringUtils.java b/solr/core/src/java/org/apache/solr/util/LocaleUtils.java
similarity index 64%
rename from solr/solrj/src/java/org/apache/solr/common/StringUtils.java
rename to solr/core/src/java/org/apache/solr/util/LocaleUtils.java
index 5d4e3f45236..4483f27d918 100644
--- a/solr/solrj/src/java/org/apache/solr/common/StringUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/LocaleUtils.java
@@ -14,22 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.common;
+package org.apache.solr.util;
-public class StringUtils {
+import java.util.Locale;
+import org.apache.solr.common.util.SuppressForbidden;
- public static boolean isEmpty(String s) {
- return (s == null) || s.isEmpty();
- }
+/** */
+public class LocaleUtils {
+
+ private LocaleUtils() {}
- /**
- * A "null-safe" equals method. Returns true if the two provided references are both null, or if
- * they are string-equal.
- */
- public static boolean equals(String first, String second) {
- if (first == null) {
- return second == null;
- }
- return first.equals(second);
+ @SuppressForbidden(reason = "Needs to use commons-lang3 LocaleUtils")
+ public static Locale toLocale(String locale) {
+ return org.apache.commons.lang3.LocaleUtils.toLocale(locale);
}
}
diff --git a/solr/core/src/java/org/apache/solr/util/ModuleUtils.java b/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
index 650006d74e0..5c0ef36604b 100644
--- a/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/ModuleUtils.java
@@ -26,7 +26,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,11 +59,11 @@ public class ModuleUtils {
// Fall back to sysprop and env.var if nothing configured through solr.xml
Set<String> mods = new HashSet<>();
String modulesFromProps = System.getProperty("solr.modules");
- if (!StringUtils.isEmpty(modulesFromProps)) {
+ if (StrUtils.isNotNullOrEmpty(modulesFromProps)) {
mods.addAll(StrUtils.splitSmart(modulesFromProps, ',', true));
}
String modulesFromEnv = System.getenv("SOLR_MODULES");
- if (!StringUtils.isEmpty(modulesFromEnv)) {
+ if (StrUtils.isNotNullOrEmpty(modulesFromEnv)) {
mods.addAll(StrUtils.splitSmart(modulesFromEnv, ',', true));
}
return mods.stream().map(String::trim).collect(Collectors.toSet());
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index d03b002e7f3..17573a73f8e 100755
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -75,8 +75,6 @@ import org.apache.commons.exec.OS;
import org.apache.commons.exec.environment.EnvironmentUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.file.PathUtils;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
@@ -91,6 +89,7 @@ import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
+import org.apache.lucene.util.Constants;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
@@ -4183,8 +4182,7 @@ public class SolrCLI implements CLIO {
private void ensureArgumentIsValidBooleanIfPresent(CommandLine cli, String argName) {
if (cli.hasOption(argName)) {
final String value = cli.getOptionValue(argName);
- final Boolean parsedBoolean = BooleanUtils.toBooleanObject(value);
- if (parsedBoolean == null) {
+ if (!"true".equalsIgnoreCase(value) && !"false".equalsIgnoreCase(value)) {
echo("Argument [" + argName + "] must be either true or false, but was [" + value + "]");
exit(1);
}
@@ -4580,7 +4578,7 @@ public class SolrCLI implements CLIO {
}
private void printAuthEnablingInstructions(String username, String password) {
- if (SystemUtils.IS_OS_WINDOWS) {
+ if (Constants.WINDOWS) {
CLIO.out(
"\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
CLIO.out(
@@ -4604,7 +4602,7 @@ public class SolrCLI implements CLIO {
}
private void printAuthEnablingInstructions(String kerberosConfig) {
- if (SystemUtils.IS_OS_WINDOWS) {
+ if (Constants.WINDOWS) {
CLIO.out(
"\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
CLIO.out(
@@ -4653,7 +4651,7 @@ public class SolrCLI implements CLIO {
includeFileLines.add(""); // blank line
if (basicAuthConfFile != null) { // for basicAuth
- if (SystemUtils.IS_OS_WINDOWS) {
+ if (Constants.WINDOWS) {
includeFileLines.add("REM The following lines added by solr.cmd for enabling BasicAuth");
includeFileLines.add("set SOLR_AUTH_TYPE=basic");
includeFileLines.add(
@@ -4667,7 +4665,7 @@ public class SolrCLI implements CLIO {
"SOLR_AUTHENTICATION_OPTS=\"-Dsolr.httpclient.config=" + basicAuthConfFile + "\"");
}
} else { // for kerberos
- if (SystemUtils.IS_OS_WINDOWS) {
+ if (Constants.WINDOWS) {
includeFileLines.add("REM The following lines added by solr.cmd for enabling BasicAuth");
includeFileLines.add("set SOLR_AUTH_TYPE=kerberos");
includeFileLines.add(
diff --git a/solr/core/src/java/org/apache/solr/util/configuration/SSLConfigurations.java b/solr/core/src/java/org/apache/solr/util/configuration/SSLConfigurations.java
index dfde4a58a35..5d5758b7948 100644
--- a/solr/core/src/java/org/apache/solr/util/configuration/SSLConfigurations.java
+++ b/solr/core/src/java/org/apache/solr/util/configuration/SSLConfigurations.java
@@ -19,7 +19,7 @@ package org.apache.solr.util.configuration;
import java.lang.invoke.MethodHandles;
import java.util.List;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,15 +60,17 @@ public class SSLConfigurations {
String clientTruststorePassword = getClientTrustStorePassword();
String truststorePassword = getTrustStorePassword();
- if (isEmpty(System.getProperty(SysProps.SSL_CLIENT_KEY_STORE_PASSWORD))
- && !(isEmpty(clientKeystorePassword) && isEmpty(keystorePassword))) {
+ if (StrUtils.isNullOrEmpty(System.getProperty(SysProps.SSL_CLIENT_KEY_STORE_PASSWORD))
+ && !(StrUtils.isNullOrEmpty(clientKeystorePassword)
+ && StrUtils.isNullOrEmpty(keystorePassword))) {
log.info("Setting {}", SysProps.SSL_CLIENT_KEY_STORE_PASSWORD);
System.setProperty(
SysProps.SSL_CLIENT_KEY_STORE_PASSWORD,
clientKeystorePassword != null ? clientKeystorePassword : keystorePassword);
}
- if (isEmpty(System.getProperty(SysProps.SSL_CLIENT_TRUST_STORE_PASSWORD))
- && !(isEmpty(clientTruststorePassword) && isEmpty(truststorePassword))) {
+ if (StrUtils.isNullOrEmpty(System.getProperty(SysProps.SSL_CLIENT_TRUST_STORE_PASSWORD))
+ && !(StrUtils.isNullOrEmpty(clientTruststorePassword)
+ && StrUtils.isNullOrEmpty(truststorePassword))) {
log.info("Setting {}", SysProps.SSL_CLIENT_TRUST_STORE_PASSWORD);
System.setProperty(
SysProps.SSL_CLIENT_TRUST_STORE_PASSWORD,
@@ -119,8 +121,4 @@ public class SSLConfigurations {
}
return null;
}
-
- private boolean isEmpty(String str) {
- return StringUtils.isEmpty(str);
- }
}
diff --git a/solr/core/src/test/org/apache/solr/CursorPagingTest.java b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
index 2cda1deb407..29663e07c3d 100644
--- a/solr/core/src/test/org/apache/solr/CursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
@@ -35,7 +35,6 @@ import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.SentinelIntSet;
import org.apache.lucene.util.mutable.MutableValueInt;
@@ -848,7 +847,9 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
"forceElevation",
"true",
"elevateIds",
- StringUtils.join(expectedElevated, ',')),
+ Arrays.stream(expectedElevated)
+ .mapToObj(String::valueOf)
+ .collect(Collectors.joining(","))),
main),
ids);
for (int expected : expectedElevated) {
diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
index 9a407ab2337..fb3a1137734 100644
--- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
+++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
@@ -31,7 +31,6 @@ import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
@@ -1558,7 +1557,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
rsp = queryServer(q);
NamedList<?> sinfo = (NamedList<?>) rsp.getResponse().get(ShardParams.SHARDS_INFO);
String shards = getShardsString();
- int cnt = StringUtils.countMatches(shards, ",") + 1;
+ int cnt = shards.length() - shards.replace(",", "").length() + 1;
assertNotNull("missing shard info", sinfo);
assertEquals(
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
index f8de32bba34..018e3fe5a1c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
@@ -23,12 +23,13 @@ import static org.apache.solr.common.params.SolrParams.wrapDefaults;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.SentinelIntSet;
import org.apache.solr.CursorPagingTest;
@@ -658,7 +659,9 @@ public class DistribCursorPagingTest extends AbstractFullDistribZkTestBase {
"forceElevation",
"true",
"elevateIds",
- StringUtils.join(expectedElevated, ',')),
+ Arrays.stream(expectedElevated)
+ .mapToObj(String::valueOf)
+ .collect(Collectors.joining(","))),
main),
ids);
for (int expected : expectedElevated) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java
index e1e75eabcc7..5b7ff3f0428 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java
@@ -19,6 +19,7 @@ package org.apache.solr.cloud;
import static java.util.Collections.singletonList;
+import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
@@ -31,7 +32,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.cloud.ZkTestServer.LimitViolationAction;
@@ -240,7 +240,10 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestB
SolrInputDocument doc = new SolrInputDocument();
addFields(doc, fields);
- addFields(doc, "rnd_s", RandomStringUtils.random(random().nextInt(100) + 100));
+ addFields(
+ doc,
+ "rnd_s",
+ RandomStrings.randomAsciiLettersOfLength(random(), random().nextInt(100) + 100));
UpdateRequest ureq = new UpdateRequest();
ureq.add(doc);
diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
index cc2df95fb15..7042c3018e2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java
@@ -19,6 +19,7 @@ package org.apache.solr.cloud;
import static java.util.Collections.singletonList;
+import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricRegistry;
@@ -35,7 +36,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.UpdateRequest;
@@ -368,7 +368,10 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {
SolrInputDocument doc = new SolrInputDocument();
addFields(doc, fields);
- addFields(doc, "rnd_s", RandomStringUtils.random(random().nextInt(100) + 100));
+ addFields(
+ doc,
+ "rnd_s",
+ RandomStrings.randomAsciiLettersOfLength(random(), random().nextInt(100) + 100));
UpdateRequest ureq = new UpdateRequest();
ureq.add(doc);
diff --git a/solr/core/src/test/org/apache/solr/cloud/ReplaceNodeTest.java b/solr/core/src/test/org/apache/solr/cloud/ReplaceNodeTest.java
index 727f433b1f9..1f40b6c7c88 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ReplaceNodeTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ReplaceNodeTest.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -326,7 +325,7 @@ public class ReplaceNodeTest extends SolrCloudTestCase {
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.set(SOURCE_NODE, sourceNode);
- if (!StringUtils.isEmpty(targetNode)) {
+ if (targetNode != null && !targetNode.isEmpty()) {
params.setNonNull(TARGET_NODE, targetNode);
}
if (parallel != null) params.set("parallel", parallel.toString());
diff --git a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
index cc751d69da4..9aed89fd306 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
@@ -26,7 +26,7 @@ import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.commons.lang3.StringUtils;
+import java.util.stream.Collectors;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
@@ -251,7 +251,7 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
// Delete the docs by query indicated.
req = new UpdateRequest();
- req.deleteByQuery("id:(" + StringUtils.join(byQueryList, " OR ") + ")");
+ req.deleteByQuery("id:(" + String.join(" OR ", byQueryList) + ")");
sendNonDirectUpdateRequestReplicaWithRetry(rep, req, expectedRfDBQ, collectionName);
}
@@ -457,7 +457,8 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
Set<Integer> docIds = getSomeIds(docsToAdd);
addDocs(collection, docIds, expectedRf, retries);
UpdateRequest req = new UpdateRequest();
- req.deleteByQuery("id:(" + StringUtils.join(docIds, " OR ") + ")");
+ req.deleteByQuery(
+ "id:(" + docIds.stream().map(String::valueOf).collect(Collectors.joining(" OR ")) + ")");
doDelete(collection, req, msg, expectedRf, retries);
}
@@ -466,7 +467,7 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
Set<Integer> docIds = getSomeIds(docsToAdd);
addDocs(collection, docIds, expectedRf, retries);
UpdateRequest req = new UpdateRequest();
- req.deleteById(StringUtils.join(docIds, ","));
+ req.deleteById(docIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
doDelete(collection, req, msg, expectedRf, retries);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
index 8bd7cd3fd9a..fbc54b8831c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java
@@ -21,7 +21,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.tests.util.LuceneTestCase.AwaitsFix;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrClient;
@@ -97,7 +96,7 @@ public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
for (Replica replica : replicas) {
assertTrue(
"Replica didn't have the proper urlScheme in the ClusterState",
- StringUtils.startsWith(replica.getStr(ZkStateReader.BASE_URL_PROP), urlScheme));
+ replica.getStr(ZkStateReader.BASE_URL_PROP).startsWith(urlScheme));
}
}
@@ -124,13 +123,12 @@ public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
- List<String> urls = new ArrayList<>();
- for (Replica replica : getReplicas()) {
- urls.add(replica.getStr(ZkStateReader.BASE_URL_PROP));
- }
+ String[] urls =
+ getReplicas().stream()
+ .map(r -> r.getStr(ZkStateReader.BASE_URL_PROP))
+ .toArray(String[]::new);
// Create new SolrServer to configure new HttpClient w/ SSL config
- try (SolrClient client =
- new LBHttpSolrClient.Builder().withBaseSolrUrls(urls.toArray(new String[] {})).build()) {
+ try (SolrClient client = new LBHttpSolrClient.Builder().withBaseSolrUrls(urls).build()) {
client.request(request);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
index 94258f6db31..90a0f1a4580 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
@@ -30,7 +30,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@@ -437,7 +436,9 @@ public class ZkCLITest extends SolrTestCaseJ4 {
ZkCLI.main(args);
assertArrayEquals(
data,
- StringUtils.removeEnd(systemOut.toString(StandardCharsets.UTF_8), System.lineSeparator())
+ systemOut
+ .toString(StandardCharsets.UTF_8)
+ .replace(System.lineSeparator(), "")
.getBytes(StandardCharsets.UTF_8));
}
@@ -460,7 +461,9 @@ public class ZkCLITest extends SolrTestCaseJ4 {
ZkCLI.main(args);
assertArrayEquals(
data,
- StringUtils.removeEnd(systemOut.toString(StandardCharsets.UTF_8), System.lineSeparator())
+ systemOut
+ .toString(StandardCharsets.UTF_8)
+ .replace(System.lineSeparator(), "")
.getBytes(StandardCharsets.UTF_8));
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/ReplicaPropertiesBase.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/ReplicaPropertiesBase.java
index 15dce24bfc9..6e81a24c1ec 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/ReplicaPropertiesBase.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/ReplicaPropertiesBase.java
@@ -20,8 +20,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -32,6 +32,7 @@ import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
// Collect useful operations for testing assigning properties to individual replicas
// Could probably expand this to do something creative with getting random slices
@@ -63,7 +64,7 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
if (replica == null) {
fail("Could not find collection/replica pair! " + collectionName + "/" + replicaName);
}
- if (StringUtils.isBlank(replica.getProperty(property))) return;
+ if (StrUtils.isBlank(replica.getProperty(property))) return;
Thread.sleep(100);
}
fail(
@@ -101,7 +102,7 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
if (replica == null) {
fail("Could not find collection/replica pair! " + collectionName + "/" + replicaName);
}
- if (StringUtils.equals(val, replica.getProperty(property))) return;
+ if (Objects.equals(val, replica.getProperty(property))) return;
Thread.sleep(100);
}
@@ -154,7 +155,7 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
for (Replica replica : slice.getReplicas()) {
uniqueNodes.add(replica.getNodeName());
String propVal = replica.getProperty(property);
- if (StringUtils.isNotBlank(propVal)) {
+ if (StrUtils.isNotBlank(propVal)) {
++propCount;
if (counts.containsKey(replica.getNodeName()) == false) {
counts.put(replica.getNodeName(), 0);
diff --git a/solr/core/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java b/solr/core/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
index 729eab2f505..68d90d80b04 100644
--- a/solr/core/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
+++ b/solr/core/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
@@ -16,7 +16,7 @@
*/
package org.apache.solr.handler;
-import org.apache.commons.lang3.ArrayUtils;
+import java.util.Arrays;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
@@ -38,7 +38,7 @@ public abstract class AnalysisRequestHandlerTestBase extends SolrTestCaseJ4 {
assertEquals(info.getPosition(), token.get("position"));
assertArrayEquals(
info.getPositionHistory(),
- ArrayUtils.toPrimitive((Integer[]) token.get("positionHistory")));
+ Arrays.stream((Integer[]) token.get("positionHistory")).mapToInt(v -> v).toArray());
if (info.isMatch()) {
assertEquals(Boolean.TRUE, token.get("match"));
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java b/solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java
index c188947954f..ed7d8c9c15d 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.solr.handler.component;
+import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.SolrServerException;
@@ -402,10 +402,10 @@ public class FacetPivot2CollectionsTest extends SolrCloudTestCase {
while (words-- > 0) {
String word = "";
if (addNonAlphaChars && (words % 3 == 0)) {
- word = RandomStringUtils.random(random.nextInt(3), "\\p{Digit}\\p{Punct}");
+ word = RandomStrings.randomAsciiAlphanumOfLength(random, random.nextInt(3));
System.out.println("generated non-alpha string:" + word);
} else {
- word = RandomStringUtils.randomAlphabetic(1, 10);
+ word = RandomStrings.randomAsciiLettersOfLengthBetween(random, 1, 10);
}
builder.append(word).append(" ");
}
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
index 05ba7cd7cb8..7e68744dc85 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
@@ -30,9 +30,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.TreeSet;
-import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.lucene.document.Document;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
@@ -244,11 +243,9 @@ public abstract class TaggerTestCase extends SolrTestCaseJ4 {
public boolean equals(Object obj) {
if (!(obj instanceof TestTag)) return false;
TestTag that = (TestTag) obj;
- return new EqualsBuilder()
- .append(this.startOffset, that.startOffset)
- .append(this.endOffset, that.endOffset)
- .append(this.docName, that.docName)
- .isEquals();
+ return this.startOffset == that.startOffset
+ && this.endOffset == that.endOffset
+ && Objects.equals(this.docName, that.docName);
}
@Override
@@ -258,11 +255,11 @@ public abstract class TaggerTestCase extends SolrTestCaseJ4 {
@Override
public int compareTo(TestTag that) {
- return new CompareToBuilder()
- .append(this.startOffset, that.startOffset)
- .append(this.endOffset, that.endOffset)
- .append(this.docName, that.docName)
- .toComparison();
+ int startOffsetCompare = Integer.compare(this.startOffset, that.startOffset);
+ if (startOffsetCompare != 0) return startOffsetCompare;
+ int endOffsetCompare = Integer.compare(this.endOffset, that.endOffset);
+ if (endOffsetCompare != 0) return endOffsetCompare;
+ return this.docName.compareTo(that.docName);
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java b/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
index a326edbcf1c..98fb2288d5d 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.document.SortedSetDocValuesField;
@@ -46,7 +45,7 @@ import org.junit.BeforeClass;
public class TestSortableTextField extends SolrTestCaseJ4 {
protected static final String BIG_CONST =
- StringUtils.repeat("x", SortableTextField.DEFAULT_MAX_CHARS_FOR_DOC_VALUES);
+ "x".repeat(SortableTextField.DEFAULT_MAX_CHARS_FOR_DOC_VALUES);
@BeforeClass
public static void create() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java
index 0baccb5e834..2232ddb508a 100644
--- a/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/security/AuditLoggerIntegrationTest.java
@@ -50,7 +50,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
@@ -533,8 +532,7 @@ public class AuditLoggerIntegrationTest extends SolrCloudAuthTestCase {
muteRules.add("\"path:/admin/info/key\"");
}
- securityJson =
- securityJson.replace("_MUTERULES_", "[" + StringUtils.join(muteRules, ",") + "]");
+ securityJson = securityJson.replace("_MUTERULES_", "[" + String.join(",", muteRules) + "]");
MiniSolrCloudCluster myCluster =
new MiniSolrCloudCluster.Builder(NUM_SERVERS, createTempDir())
diff --git a/solr/modules/hadoop-auth/src/java/org/apache/solr/util/configuration/providers/hadoop/HadoopSSLCredentialProvider.java b/solr/modules/hadoop-auth/src/java/org/apache/solr/util/configuration/providers/hadoop/HadoopSSLCredentialProvider.java
index 2c37615fc57..481aa4d96c3 100644
--- a/solr/modules/hadoop-auth/src/java/org/apache/solr/util/configuration/providers/hadoop/HadoopSSLCredentialProvider.java
+++ b/solr/modules/hadoop-auth/src/java/org/apache/solr/util/configuration/providers/hadoop/HadoopSSLCredentialProvider.java
@@ -23,7 +23,7 @@ import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.EnumMap;
import org.apache.hadoop.conf.Configuration;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.util.configuration.providers.AbstractSSLCredentialProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +40,7 @@ public class HadoopSSLCredentialProvider extends AbstractSSLCredentialProvider {
}
public HadoopSSLCredentialProvider(Configuration hadoopConfigurationProvider) {
- if (StringUtils.isEmpty(System.getProperty(CREDENTIAL_PROVIDER_PATH))) {
+ if (StrUtils.isNullOrEmpty(System.getProperty(CREDENTIAL_PROVIDER_PATH))) {
throw new RuntimeException(
"Cannot initialize Hadoop configuration provider without credential provider path. Use "
+ CREDENTIAL_PROVIDER_PATH
diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
index f80638517cb..d79aadb1811 100644
--- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
+++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java
@@ -51,10 +51,10 @@ import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.api.collections.SplitShardCmd;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CachingDirectoryFactory;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.DirectoryFactory;
@@ -186,7 +186,8 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory
if (kerberosEnabled) {
initKerberos();
}
- if (StringUtils.isEmpty(System.getProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED))) {
+ if (StrUtils.isNullOrEmpty(
+ System.getProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED))) {
System.setProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED, "false");
}
}
diff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/HdfsTestUtil.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/HdfsTestUtil.java
index b943920a37f..f2452b7fece 100644
--- a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/HdfsTestUtil.java
+++ b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/HdfsTestUtil.java
@@ -31,7 +31,6 @@ import java.util.TimerTask;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.regex.Pattern;
-import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
@@ -149,7 +148,7 @@ public class HdfsTestUtil {
@SuppressForbidden(reason = "Call FastDateFormat.format same way Hadoop calls it")
private static void checkFastDateFormat() {
try {
- FastDateFormat.getInstance().format(System.currentTimeMillis());
+ org.apache.commons.lang3.time.FastDateFormat.getInstance().format(System.currentTimeMillis());
} catch (ArrayIndexOutOfBoundsException e) {
SolrTestCaseJ4.assumeNoException(
"commons-lang3 FastDateFormat doesn't work with " + Locale.getDefault().toLanguageTag(),
diff --git a/solr/modules/jwt-auth/build.gradle b/solr/modules/jwt-auth/build.gradle
index 2553d7381c6..abbf9582b44 100644
--- a/solr/modules/jwt-auth/build.gradle
+++ b/solr/modules/jwt-auth/build.gradle
@@ -61,5 +61,4 @@ dependencies {
testImplementation 'com.squareup.okhttp3:mockwebserver'
testImplementation 'com.squareup.okhttp3:okhttp'
testRuntimeOnly 'io.netty:netty-codec-http'
- testImplementation 'org.apache.commons:commons-lang3'
}
diff --git a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java
index a51f2208eea..ae20606f7e7 100644
--- a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java
+++ b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java
@@ -54,8 +54,8 @@ import org.apache.solr.api.Api;
import org.apache.solr.client.solrj.impl.Http2SolrClient;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SpecProvider;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.CommandOperation;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.common.util.ValidatingJsonMap;
import org.apache.solr.core.CoreContainer;
@@ -206,7 +206,7 @@ public class JWTAuthPlugin extends AuthenticationPlugin
}
String requiredScopesStr = (String) pluginConfig.get(PARAM_SCOPE);
- if (!StringUtils.isEmpty(requiredScopesStr)) {
+ if (StrUtils.isNotNullOrEmpty(requiredScopesStr)) {
requiredScopes = Arrays.asList(requiredScopesStr.split("\\s+"));
}
diff --git a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java
index 29e70780f80..3355486001a 100644
--- a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java
+++ b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.solr.SolrTestCase;
import org.apache.solr.common.SolrException;
import org.jose4j.jwk.JsonWebKeySet;
@@ -168,7 +167,7 @@ public class JWTIssuerConfigTest extends SolrTestCase {
@Test
public void wellKnownConfigFromString() throws IOException {
Path configJson = JWT_TEST_PATH().resolve("security").resolve("jwt_well-known-config.json");
- String configString = StringUtils.join(Files.readAllLines(configJson), "\n");
+ String configString = String.join("\n", Files.readAllLines(configJson));
JWTIssuerConfig.WellKnownDiscoveryConfig config =
JWTIssuerConfig.WellKnownDiscoveryConfig.parse(configString, StandardCharsets.UTF_8);
assertEquals("https://acmepaymentscorp/oauth/jwks", config.getJwksUrl());
diff --git a/solr/modules/s3-repository/build.gradle b/solr/modules/s3-repository/build.gradle
index 4660660c8f7..b8a9763e907 100644
--- a/solr/modules/s3-repository/build.gradle
+++ b/solr/modules/s3-repository/build.gradle
@@ -78,7 +78,6 @@ dependencies {
}
testImplementation 'commons-io:commons-io'
- testImplementation 'org.apache.commons:commons-lang3'
testRuntimeOnly 'org.eclipse.jetty:jetty-webapp'
}
diff --git a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3BackupRepository.java b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3BackupRepository.java
index cfa04e245ad..2f5f543360a 100644
--- a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3BackupRepository.java
+++ b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3BackupRepository.java
@@ -36,8 +36,8 @@ import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.backup.repository.BackupRepository;
import org.slf4j.Logger;
@@ -78,7 +78,7 @@ public class S3BackupRepository implements BackupRepository {
@Override
public URI createURI(String location) {
- if (StringUtils.isEmpty(location)) {
+ if (StrUtils.isNullOrEmpty(location)) {
throw new IllegalArgumentException("cannot create URI with an empty location");
}
@@ -99,7 +99,7 @@ public class S3BackupRepository implements BackupRepository {
@Override
public URI createDirectoryURI(String location) {
- if (StringUtils.isEmpty(location)) {
+ if (StrUtils.isNullOrEmpty(location)) {
throw new IllegalArgumentException("cannot create URI with an empty location");
}
@@ -202,7 +202,7 @@ public class S3BackupRepository implements BackupRepository {
@Override
public IndexInput openInput(URI path, String fileName, IOContext ctx) throws IOException {
Objects.requireNonNull(path, "cannot open a input stream without a valid URI path");
- if (StringUtils.isEmpty(fileName)) {
+ if (StrUtils.isNullOrEmpty(fileName)) {
throw new IllegalArgumentException("need a valid file name to read from S3");
}
@@ -272,10 +272,10 @@ public class S3BackupRepository implements BackupRepository {
public void copyIndexFileFrom(
Directory sourceDir, String sourceFileName, URI dest, String destFileName)
throws IOException {
- if (StringUtils.isEmpty(sourceFileName)) {
+ if (StrUtils.isNullOrEmpty(sourceFileName)) {
throw new IllegalArgumentException("must have a valid source file name to copy");
}
- if (StringUtils.isEmpty(destFileName)) {
+ if (StrUtils.isNullOrEmpty(destFileName)) {
throw new IllegalArgumentException("must have a valid destination file name to copy");
}
@@ -329,10 +329,10 @@ public class S3BackupRepository implements BackupRepository {
public void copyIndexFileTo(
URI sourceDir, String sourceFileName, Directory dest, String destFileName)
throws IOException {
- if (StringUtils.isEmpty(sourceFileName)) {
+ if (StrUtils.isNullOrEmpty(sourceFileName)) {
throw new IllegalArgumentException("must have a valid source file name to copy");
}
- if (StringUtils.isEmpty(destFileName)) {
+ if (StrUtils.isNullOrEmpty(destFileName)) {
throw new IllegalArgumentException("must have a valid destination file name to copy");
}
diff --git a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
index 08b67b1c8ce..3d600899647 100644
--- a/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
+++ b/solr/modules/s3-repository/src/java/org/apache/solr/s3/S3StorageClient.java
@@ -31,7 +31,7 @@ import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.SuppressForbidden;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,14 +116,14 @@ public class S3StorageClient {
String endpoint,
boolean disableRetries) {
S3Configuration.Builder configBuilder = S3Configuration.builder().pathStyleAccessEnabled(true);
- if (!StringUtils.isEmpty(profile)) {
+ if (StrUtils.isNotNullOrEmpty(profile)) {
configBuilder.profileName(profile);
}
ApacheHttpClient.Builder sdkHttpClientBuilder = ApacheHttpClient.builder();
// If configured, add proxy
ProxyConfiguration.Builder proxyConfigurationBuilder = ProxyConfiguration.builder();
- if (!StringUtils.isEmpty(proxyUrl)) {
+ if (StrUtils.isNotNullOrEmpty(proxyUrl)) {
proxyConfigurationBuilder.endpoint(URI.create(proxyUrl));
} else {
proxyConfigurationBuilder.useSystemPropertyValues(proxyUseSystemSettings);
@@ -139,7 +139,7 @@ public class S3StorageClient {
retryPolicy = RetryPolicy.none();
} else {
RetryMode.Resolver retryModeResolver = RetryMode.resolver();
- if (!StringUtils.isEmpty(profile)) {
+ if (StrUtils.isNotNullOrEmpty(profile)) {
retryModeResolver.profileName(profile);
}
RetryMode retryMode = retryModeResolver.resolve();
@@ -158,7 +158,7 @@ public class S3StorageClient {
*/
DefaultCredentialsProvider.Builder credentialsProviderBuilder =
DefaultCredentialsProvider.builder();
- if (!StringUtils.isEmpty(profile)) {
+ if (StrUtils.isNotNullOrEmpty(profile)) {
credentialsProviderBuilder.profileName(profile);
}
@@ -172,10 +172,10 @@ public class S3StorageClient {
.serviceConfiguration(configBuilder.build())
.httpClient(sdkHttpClientBuilder.build());
- if (!StringUtils.isEmpty(endpoint)) {
+ if (StrUtils.isNotNullOrEmpty(endpoint)) {
clientBuilder.endpointOverride(URI.create(endpoint));
}
- if (!StringUtils.isEmpty(region)) {
+ if (StrUtils.isNotNullOrEmpty(region)) {
clientBuilder.region(Region.of(region));
}
@@ -329,7 +329,8 @@ public class S3StorageClient {
s3Client.headObject(builder -> builder.bucket(bucketName).key(s3Path));
String contentType = objectMetadata.contentType();
- return !StringUtils.isEmpty(contentType) && contentType.equalsIgnoreCase(S3_DIR_CONTENT_TYPE);
+ return StrUtils.isNotNullOrEmpty(contentType)
+ && contentType.equalsIgnoreCase(S3_DIR_CONTENT_TYPE);
} catch (NoSuchKeyException nske) {
return false;
} catch (SdkException sdke) {
@@ -353,7 +354,8 @@ public class S3StorageClient {
s3Client.headObject(b -> b.bucket(bucketName).key(s3Path));
String contentType = objectMetadata.contentType();
- if (StringUtils.isEmpty(contentType) || !contentType.equalsIgnoreCase(S3_DIR_CONTENT_TYPE)) {
+ if (StrUtils.isNullOrEmpty(contentType)
+ || !contentType.equalsIgnoreCase(S3_DIR_CONTENT_TYPE)) {
return objectMetadata.contentLength();
}
throw new S3Exception("Path is Directory");
diff --git a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IndexInputTest.java b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IndexInputTest.java
index 0f9e906b296..a52fdab0fb7 100644
--- a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IndexInputTest.java
+++ b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IndexInputTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.s3;
+import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -24,7 +25,6 @@ import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.Rule;
import org.junit.Test;
@@ -53,7 +53,7 @@ public class S3IndexInputTest extends SolrTestCaseJ4 {
public void testPartialReadBigSlice() throws IOException {
// Large text, be sure we can't read in a single I/O call
int length = S3IndexInput.LOCAL_BUFFER_SIZE * 10 + 5;
- String content = RandomStringUtils.randomAscii(length);
+ String content = RandomStrings.randomAsciiAlphanumOfLength(random(), length);
int slice = S3IndexInput.LOCAL_BUFFER_SIZE * 2;
doTestPartialRead(false, content, slice);
diff --git a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3OutputStreamTest.java b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3OutputStreamTest.java
index 44177d41265..1116d3103d4 100644
--- a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3OutputStreamTest.java
+++ b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3OutputStreamTest.java
@@ -17,10 +17,10 @@
package org.apache.solr.s3;
import com.adobe.testing.s3mock.junit4.S3MockRule;
+import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.After;
import org.junit.Before;
@@ -92,7 +92,8 @@ public class S3OutputStreamTest extends SolrTestCaseJ4 {
@Test
public void testWriteLargeBuffer() throws IOException {
// must be larger than S3 part size
- String content = RandomStringUtils.randomAlphanumeric(S3OutputStream.PART_SIZE + 1024);
+ String content =
+ RandomStrings.randomAsciiAlphanumOfLength(random(), S3OutputStream.PART_SIZE + 1024);
byte[] buffer = content.getBytes(StandardCharsets.UTF_8);
// pre-check -- ensure that our test string isn't too small
assertTrue(buffer.length > S3OutputStream.PART_SIZE);
@@ -137,7 +138,8 @@ public class S3OutputStreamTest extends SolrTestCaseJ4 {
@Test
public void testFlushLargeBuffer() throws IOException {
// must be larger than S3 minimal part size, so we actually do something for flush()
- String content = RandomStringUtils.randomAlphanumeric(S3OutputStream.MIN_PART_SIZE + 1024);
+ String content =
+ RandomStrings.randomAsciiAlphanumOfLength(random(), S3OutputStream.MIN_PART_SIZE + 1024);
byte[] buffer = content.getBytes(StandardCharsets.UTF_8);
assertTrue(buffer.length > S3OutputStream.MIN_PART_SIZE);
diff --git a/solr/modules/sql/build.gradle b/solr/modules/sql/build.gradle
index 7afabae221c..5a8bf946334 100644
--- a/solr/modules/sql/build.gradle
+++ b/solr/modules/sql/build.gradle
@@ -47,8 +47,6 @@ dependencies {
testImplementation 'junit:junit'
testRuntimeOnly project(':solr:modules:analysis-extras')
-
- testImplementation 'org.apache.commons:commons-lang3'
}
diff --git a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
index 77d51bc30cb..c1a15aad586 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java
@@ -46,7 +46,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.util.Pair;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.handler.sql.functions.ArrayContainsAll;
import org.apache.solr.handler.sql.functions.ArrayContainsAny;
import org.slf4j.Logger;
@@ -171,7 +171,7 @@ class SolrFilter extends Filter implements SolrRel {
RexNode valuesNode = operands.get(1);
if (valuesNode instanceof RexLiteral) {
String literal = toSolrLiteral(fieldName, (RexLiteral) valuesNode);
- if (!StringUtils.isEmpty(literal)) {
+ if (StrUtils.isNotNullOrEmpty(literal)) {
return fieldName + ":\"" + ClientUtils.escapeQueryChars(literal.trim()) + "\"";
} else {
return null;
@@ -181,7 +181,7 @@ class SolrFilter extends Filter implements SolrRel {
String valuesString =
valuesRexCall.getOperands().stream()
.map(op -> toSolrLiteral(fieldName, (RexLiteral) op))
- .filter(value -> !StringUtils.isEmpty(value))
+ .filter(StrUtils::isNotNullOrEmpty)
.map(value -> "\"" + ClientUtils.escapeQueryChars(value.trim()) + "\"")
.collect(Collectors.joining(" " + booleanOperator + " "));
return fieldName + ":(" + valuesString + ")";
diff --git a/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandler.java b/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandler.java
index b587a5c6bbb..1283ca7e372 100644
--- a/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandler.java
+++ b/solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandler.java
@@ -17,6 +17,9 @@
package org.apache.solr.handler.sql;
import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,7 +28,6 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.io.Tuple;
@@ -3131,10 +3133,11 @@ public class TestSQLHandler extends SolrCloudTestCase {
@Test
public void testManyInValues() throws Exception {
int maxSize = 1000;
- int width = 4;
+ NumberFormat formatter =
+ new DecimalFormat("0000", DecimalFormatSymbols.getInstance(Locale.ROOT));
List<String> bigList = new ArrayList<>(maxSize);
for (int i = 0; i < maxSize; i++) {
- bigList.add(StringUtils.leftPad(String.valueOf(i), width, "0"));
+ bigList.add(formatter.format(i));
}
UpdateRequest update = new UpdateRequest();
diff --git a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/MetricsConfiguration.java b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/MetricsConfiguration.java
index 28b923b2e4c..6c4939c3b91 100644
--- a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/MetricsConfiguration.java
+++ b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/MetricsConfiguration.java
@@ -31,7 +31,7 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import net.thisptr.jackson.jq.exception.JsonQueryException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -174,7 +174,7 @@ public class MetricsConfiguration {
Node nameAttr = template.getAttributes().getNamedItem("name");
String name = nameAttr != null ? nameAttr.getNodeValue() : null;
String tmpl = template.getTextContent();
- if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(tmpl)) {
+ if (StrUtils.isNotNullOrEmpty(name) && StrUtils.isNotNullOrEmpty(tmpl)) {
Node defaultTypeAttr = template.getAttributes().getNamedItem("defaultType");
String defaultType = defaultTypeAttr != null ? defaultTypeAttr.getNodeValue() : null;
map.put(name, new MetricsQueryTemplate(name, tmpl, defaultType));
diff --git a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
index 355a5f6e2ce..2cad046fa44 100644
--- a/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
+++ b/solr/prometheus-exporter/src/java/org/apache/solr/prometheus/exporter/SolrExporter.java
@@ -27,10 +27,10 @@ import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.prometheus.collector.MetricsCollectorFactory;
import org.apache.solr.prometheus.collector.SchedulerMetricsCollector;
import org.apache.solr.prometheus.scraper.SolrCloudScraper;
@@ -262,7 +262,7 @@ public class SolrExporter {
int port = res.getInt(ARG_PORT_DEST);
String clusterId = res.getString(ARG_CLUSTER_ID_DEST);
- if (StringUtils.isEmpty(clusterId)) {
+ if (StrUtils.isNullOrEmpty(clusterId)) {
clusterId = defaultClusterId;
}
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkACLProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkACLProvider.java
index eb3f3c2b1c6..314990ff278 100755
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkACLProvider.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkACLProvider.java
@@ -23,8 +23,8 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ZkCredentialsInjector.ZkCredential;
+import org.apache.solr.common.util.StrUtils;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
@@ -68,8 +68,8 @@ public class DigestZkACLProvider extends SecurityAwareZkACLProvider {
List<ZkCredential> zkCredentials = zkCredentialsInjector.getZkCredentials();
log.debug("createACLsToAdd using ZkCredentials: {}", zkCredentials);
for (ZkCredential zkCredential : zkCredentials) {
- if (StringUtils.isEmpty(zkCredential.getUsername())
- || StringUtils.isEmpty(zkCredential.getPassword())) {
+ if (StrUtils.isNullOrEmpty(zkCredential.getUsername())
+ || StrUtils.isNullOrEmpty(zkCredential.getPassword())) {
continue;
}
Id id = createACLId(zkCredential.getUsername(), zkCredential.getPassword());
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkCredentialsProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkCredentialsProvider.java
index 1b8092c8733..cfe30286dc9 100755
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkCredentialsProvider.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/DigestZkCredentialsProvider.java
@@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,8 +49,8 @@ public class DigestZkCredentialsProvider extends DefaultZkCredentialsProvider {
for (ZkCredentialsInjector.ZkCredential zkCredential : zkCredentials) {
if (zkCredential.isAll()) {
// this is the "user" with all perms that SolrZooKeeper uses to connect to zookeeper
- if (!StringUtils.isEmpty(zkCredential.getUsername())
- && !StringUtils.isEmpty(zkCredential.getPassword())) {
+ if (StrUtils.isNotNullOrEmpty(zkCredential.getUsername())
+ && StrUtils.isNotNullOrEmpty(zkCredential.getPassword())) {
result.add(
new ZkCredentials(
"digest",
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index 49176ee1f68..ccfb71b726e 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -36,7 +36,6 @@ import java.util.regex.Pattern;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.annotation.JsonProperty;
import org.apache.solr.common.cloud.ConnectionManager.IsClosed;
import org.apache.solr.common.util.Compressor;
@@ -44,6 +43,7 @@ import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.ObjectReleaseTracker;
import org.apache.solr.common.util.ReflectMapWriter;
import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.ZLibCompressor;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -232,7 +232,7 @@ public class SolrZkClient implements Closeable {
protected ZkCredentialsProvider createZkCredentialsToAddAutomatically() {
String zkCredentialsProviderClassName =
System.getProperty(ZK_CRED_PROVIDER_CLASS_NAME_VM_PARAM_NAME);
- if (!StringUtils.isEmpty(zkCredentialsProviderClassName)) {
+ if (StrUtils.isNotNullOrEmpty(zkCredentialsProviderClassName)) {
try {
log.info("Using ZkCredentialsProvider: {}", zkCredentialsProviderClassName);
ZkCredentialsProvider zkCredentialsProvider =
@@ -257,7 +257,7 @@ public class SolrZkClient implements Closeable {
protected ZkACLProvider createZkACLProvider() {
String zkACLProviderClassName = System.getProperty(ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME);
- if (!StringUtils.isEmpty(zkACLProviderClassName)) {
+ if (StrUtils.isNotNullOrEmpty(zkACLProviderClassName)) {
try {
log.info("Using ZkACLProvider: {}", zkACLProviderClassName);
ZkACLProvider zkACLProvider =
@@ -285,7 +285,7 @@ public class SolrZkClient implements Closeable {
protected ZkCredentialsInjector createZkCredentialsInjector() {
String zkCredentialsInjectorClassName =
System.getProperty(ZK_CREDENTIALS_INJECTOR_CLASS_NAME_VM_PARAM_NAME);
- if (!StringUtils.isEmpty(zkCredentialsInjectorClassName)) {
+ if (StrUtils.isNotNullOrEmpty(zkCredentialsInjectorClassName)) {
try {
log.info("Using ZkCredentialsInjector: {}", zkCredentialsInjectorClassName);
return Class.forName(zkCredentialsInjectorClassName)
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkDynamicConfig.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkDynamicConfig.java
index cb741075bc0..0bc8858a3dc 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkDynamicConfig.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkDynamicConfig.java
@@ -24,7 +24,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
/**
* Class holding the dynamic config of a Zookeeper ensemble as fetched from znode <code>
@@ -54,7 +54,7 @@ public class ZkDynamicConfig {
*/
public static ZkDynamicConfig parseLines(String lines) {
ZkDynamicConfig zkDynamicConfig = new ZkDynamicConfig();
- if (!StringUtils.isEmpty(lines)) {
+ if (StrUtils.isNotNullOrEmpty(lines)) {
lines
.lines()
.forEach(
diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
index 8fd0731b685..7ade32ebf3d 100644
--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
@@ -34,7 +34,7 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.common.StringUtils;
+import org.apache.solr.common.util.StrUtils;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
@@ -521,7 +521,7 @@ public class ZkMaintenanceUtils {
// Will return empty string if the path is just "/"
// Will return empty string if the path is just ""
public static String getZkParent(String path) {
- if (StringUtils.isEmpty(path) || "/".equals(path)) {
+ if (StrUtils.isNullOrEmpty(path) || "/".equals(path)) {
return "";
}
// Remove trailing slash if present.
@@ -578,7 +578,7 @@ public class ZkMaintenanceUtils {
String userForbiddenFileTypes =
System.getProperty(
FORBIDDEN_FILE_TYPES_PROP, System.getenv(FORBIDDEN_FILE_TYPES_ENV));
- if (StringUtils.isEmpty(userForbiddenFileTypes)) {
+ if (StrUtils.isNullOrEmpty(userForbiddenFileTypes)) {
USE_FORBIDDEN_FILE_TYPES = DEFAULT_FORBIDDEN_FILE_TYPES;
} else {
USE_FORBIDDEN_FILE_TYPES = Set.of(userForbiddenFileTypes.split(","));
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
index 30431184abb..b4e65fe4a45 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
@@ -36,7 +36,6 @@ import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
@@ -1142,7 +1141,7 @@ public abstract class SolrClient implements Serializable, Closeable {
}
ModifiableSolrParams reqParams = new ModifiableSolrParams(params);
- if (StringUtils.isEmpty(reqParams.get(CommonParams.QT))) {
+ if (StrUtils.isNullOrEmpty(reqParams.get(CommonParams.QT))) {
reqParams.set(CommonParams.QT, "/get");
}
reqParams.set(
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index fe7a5615d38..cc0f9e3e6f2 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -23,6 +23,7 @@ import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.Locale;
+import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
@@ -43,7 +44,6 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
@@ -248,7 +248,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
UpdateRequest req = upd.getRequest();
SolrParams currentParams = new ModifiableSolrParams(req.getParams());
if (!origParams.toNamedList().equals(currentParams.toNamedList())
- || !StringUtils.equals(origTargetCollection, upd.getCollection())) {
+ || !Objects.equals(origTargetCollection, upd.getCollection())) {
// Request has different params or destination core/collection, return to
// queue
queue.add(upd);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 92dbeaa8868..33489afc0d0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -42,6 +42,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -64,7 +65,6 @@ import org.apache.solr.client.solrj.util.AsyncListener;
import org.apache.solr.client.solrj.util.Cancellable;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
@@ -347,11 +347,8 @@ public class Http2SolrClient extends SolrClient {
boolean belongToThisStream(SolrRequest<?> solrRequest, String collection) {
ModifiableSolrParams solrParams = new ModifiableSolrParams(solrRequest.getParams());
- if (!origParams.toNamedList().equals(solrParams.toNamedList())
- || !StringUtils.equals(origCollection, collection)) {
- return false;
- }
- return true;
+ return origParams.toNamedList().equals(solrParams.toNamedList())
+ && Objects.equals(origCollection, collection);
}
public void write(byte b[]) throws IOException {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientBuilderFactory.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientBuilderFactory.java
index b2d2d56922d..89a097f9f38 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientBuilderFactory.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/PreemptiveBasicAuthClientBuilderFactory.java
@@ -32,7 +32,6 @@ import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.solr.client.solrj.util.SolrBasicAuthentication;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.StrUtils;
@@ -153,7 +152,9 @@ public class PreemptiveBasicAuthClientBuilderFactory implements HttpClientBuilde
if (credentials != null) {
List<String> ss = StrUtils.splitSmart(credentials, ':');
- if (ss.size() != 2 || StringUtils.isEmpty(ss.get(0)) || StringUtils.isEmpty(ss.get(1))) {
+ if (ss.size() != 2
+ || StrUtils.isNullOrEmpty(ss.get(0))
+ || StrUtils.isNullOrEmpty(ss.get(1))) {
throw new IllegalArgumentException(
"Invalid Authentication credentials: Please provide 'basicauth' in the 'user:password' format");
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 2950c9bcb16..33df04ca7b2 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -47,7 +47,6 @@ import org.apache.solr.client.solrj.response.RequestStatusState;
import org.apache.solr.client.solrj.util.SolrIdentifierValidator;
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.ImplicitDocRouter;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.CollectionAdminParams;
@@ -60,6 +59,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.StrUtils;
/**
* This class is experimental and subject to change.
@@ -793,7 +793,7 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.set(CollectionParams.SOURCE_NODE, sourceNode);
- if (!StringUtils.isEmpty(targetNode)) {
+ if (StrUtils.isNotNullOrEmpty(targetNode)) {
params.set(CollectionParams.TARGET_NODE, targetNode);
}
if (parallel != null) params.set("parallel", parallel.toString());
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java
index f53f1003795..cc72caf5696 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/routing/NodePreferenceRulesComparator.java
@@ -22,11 +22,11 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
-import org.apache.solr.common.StringUtils;
import org.apache.solr.common.cloud.NodesSysProps;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.StrUtils;
/**
* This comparator makes sure that the given replicas are sorted according to the given list of
@@ -184,7 +184,7 @@ public class NodePreferenceRulesComparator implements Comparator<Object> {
return false;
}
if (prefix.equals(ShardParams.REPLICA_LOCAL)) {
- return !StringUtils.isEmpty(localHostAddress) && s.startsWith(localHostAddress);
+ return StrUtils.isNotNullOrEmpty(localHostAddress) && s.startsWith(localHostAddress);
} else {
return s.startsWith(prefix);
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
index b9bab2ae88e..0a6ed1464ca 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java
@@ -367,6 +367,18 @@ public class StrUtils {
return string == null || string.isEmpty();
}
+ public static boolean isNotNullOrEmpty(String string) {
+ return !isNullOrEmpty(string);
+ }
+
+ public static boolean isBlank(String string) {
+ return string == null || string.isBlank();
+ }
+
+ public static boolean isNotBlank(String string) {
+ return !isBlank(string);
+ }
+
public static String stringFromReader(Reader inReader) throws IOException {
try (Reader reader = inReader) {
StringWriter stringWriter = new StringWriter();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
index 928d1e319b5..c75b0bf053c 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClientUtilTest.java
@@ -24,7 +24,6 @@ import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipException;
import javax.net.ssl.HostnameVerifier;
-import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.http.HttpEntity;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
@@ -36,6 +35,7 @@ import org.apache.http.entity.StringEntity;
import org.apache.lucene.tests.util.TestRuleRestoreSystemProperties;
import org.apache.solr.SolrTestCase;
import org.apache.solr.client.solrj.impl.HttpClientUtil.SocketFactoryRegistryProvider;
+import org.apache.solr.common.util.SuppressForbidden;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -88,13 +88,19 @@ public class HttpClientUtilTest extends SolrTestCase {
"socketFactory is not an SSLConnectionSocketFactory: " + socketFactory.getClass(),
socketFactory instanceof SSLConnectionSocketFactory);
SSLConnectionSocketFactory sslSocketFactory = (SSLConnectionSocketFactory) socketFactory;
+ Object hostnameVerifier = getHostnameVerifier(sslSocketFactory);
+ assertNotNull("sslSocketFactory has null hostnameVerifier", hostnameVerifier);
+ assertEquals(
+ "sslSocketFactory does not have expected hostnameVerifier impl",
+ expected,
+ hostnameVerifier.getClass());
+ }
+
+ @SuppressForbidden(reason = "Uses commons-lang3 FieldUtils.readField to get hostnameVerifier")
+ private Object getHostnameVerifier(SSLConnectionSocketFactory sslSocketFactory) {
try {
- Object hostnameVerifier = FieldUtils.readField(sslSocketFactory, "hostnameVerifier", true);
- assertNotNull("sslSocketFactory has null hostnameVerifier", hostnameVerifier);
- assertEquals(
- "sslSocketFactory does not have expected hostnameVerifier impl",
- expected,
- hostnameVerifier.getClass());
+ return org.apache.commons.lang3.reflect.FieldUtils.readField(
+ sslSocketFactory, "hostnameVerifier", true);
} catch (IllegalAccessException e) {
throw new AssertionError("Unexpected access error reading hostnameVerifier field", e);
}