Skip to content

Commit

Permalink
SOLR-16427: Evaluate and fix errorprone rules - MissingOverride
Browse files Browse the repository at this point in the history
  • Loading branch information
risdenk committed Oct 26, 2022
1 parent 5cc612f commit 5465b01
Show file tree
Hide file tree
Showing 468 changed files with 1,554 additions and 2 deletions.
1 change: 0 additions & 1 deletion gradle/validation/error-prone.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ allprojects { prj ->
'-Xep:InvalidBlockTag:OFF', // this is needed for tags like lucene.internal
'-Xep:JavaUtilDate:OFF',
'-Xep:LogicalAssignment:OFF',
'-Xep:MissingOverride:OFF',
'-Xep:MissingSummary:OFF',
'-Xep:MixedMutabilityReturnType:OFF',
'-Xep:ModifiedButNotUsed:OFF',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public SplittableRandomGenerator(long seed) {
this.random = new SplittableRandom(seed);
}

@Override
public void setSeed(int seed) {
setSeed((long) seed);
}

@Override
public void setSeed(int[] seed) {
setSeed(RandomGeneratorFactory.convertToLong(seed));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public List<RandomDataHistogram.Counts.Surrogate> values() {
return Collections.unmodifiableList(values);
}

@Override
public String toString() {
return String.format(
Locale.ENGLISH, "%s (%s, %s%%): %s", name, count, percentage, Tracker.display(values));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private BenchmarkRandomSource(
this.distribution = distribution;
}

@Override
public BenchmarkRandomSource withDistribution(Distribution distribution) {
if (this.distribution == distribution) {
return this;
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/api/AnnotatedApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ void invoke(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation cmd) {
}
}

@Override
public int hashCode() {
return new HashCodeBuilder()
.append(command)
Expand All @@ -348,6 +349,7 @@ public int hashCode() {
.toHashCode();
}

@Override
public boolean equals(Object rhs) {
if (null == rhs) return false;
if (this == rhs) return true;
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/api/ApiBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public IntrospectApi(Api base, boolean isCoreSpecific) {
this.isCoreSpecific = isCoreSpecific;
}

@Override
@SuppressWarnings({"unchecked"})
public void call(SolrQueryRequest req, SolrQueryResponse rsp) {

Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/api/V2HttpCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public V2HttpCall(
super(solrDispatchFilter, cc, request, response, retry);
}

@Override
@SuppressForbidden(
reason =
"Set the thread contextClassLoader for all 3rd party dependencies that we cannot control")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public ElectionContext(
this.zkClient = zkClient;
}

@Override
public void close() {}

public void cancelElection() throws InterruptedException, KeeperException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ private static class SliceReplica {
this.replica = replica;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder(System.lineSeparator()).append(System.lineSeparator());
sb.append(" :")
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cloud/Overseer.java
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ public synchronized OverseerThread getUpdaterThread() {
return updaterThread;
}

@Override
public synchronized void close() {
if (this.id != null) {
log.info("Overseer (id={}) closing", id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ private void cleanUpWorkQueue() throws KeeperException, InterruptedException {
}
}

@Override
public void close() {
isClosed = true;
overseerTaskProcessorMetricsContext.unregister();
Expand Down Expand Up @@ -548,6 +549,7 @@ public Runner(
response = null;
}

@Override
public void run() {
String statsName = messageHandler.getTimerName(operation);
final Timer.Context timerContext = stats.time(statsName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public RefreshCollectionMessage(String collection) {
this.collection = collection;
}

@Override
public ClusterState run(ClusterState clusterState, Overseer overseer, ZkStateWriter zkStateWriter)
throws Exception {
Stat stat =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void remove(String shardId, CoreDescriptor coreDescriptor) {
}
}

@Override
public void close() {
synchronized (terms) {
terms.values().forEach(ZkShardTerms::close);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public void deleteFilesFromConfig(String configName, List<String> filesToDelete)
}
}

@Override
public void copyConfig(String fromConfig, String toConfig) throws IOException {
String fromConfigPath = CONFIGS_ZKNODE + "/" + fromConfig;
String toConfigPath = CONFIGS_ZKNODE + "/" + toConfig;
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ private class RegisterCoreAsync implements Callable<Object> {
this.afterExpiration = afterExpiration;
}

@Override
public Object call() throws Exception {
if (log.isInfoEnabled()) {
log.info("Registering core {} afterExpiration? {}", descriptor.getName(), afterExpiration);
Expand Down Expand Up @@ -737,6 +738,7 @@ public void preClose() {
}

/** Closes the underlying ZooKeeper client. */
@Override
public void close() {
if (!this.isClosed) preClose();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public ZkDistributedCollectionLockFactory(SolrZkClient zkClient, String rootPath
super(zkClient, rootPath);
}

@Override
public DistributedLock createLock(
boolean isWriteLock,
CollectionParams.LockLevel level,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public ZkDistributedConfigSetLockFactory(SolrZkClient zkClient, String rootPath)
super(zkClient, rootPath);
}

@Override
public DistributedLock createLock(boolean isWriteLock, String configSetName) {
Preconditions.checkArgument(configSetName != null, "configSetName can't be null");

Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public boolean registered(String coreNodeName) {
return terms.get().getTerm(coreNodeName) != null;
}

@Override
public void close() {
// no watcher will be registered
isClosed.set(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ CollApiCmds.CollectionApiCommand getActionCommand(CollectionParams.CollectionAct
}

public static class MockOperationCmd implements CollectionApiCommand {
@Override
@SuppressForbidden(reason = "Needs currentTimeMillis for mock requests")
public void call(ClusterState state, ZkNodeProps message, NamedList<Object> results)
throws InterruptedException {
Expand All @@ -207,6 +208,7 @@ public ReloadCollectionCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.RELOAD.toString());
Expand All @@ -231,6 +233,7 @@ public RebalanceLeadersCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {
CollectionHandlingUtils.checkRequired(
Expand Down Expand Up @@ -275,6 +278,7 @@ public AddReplicaPropCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {
CollectionHandlingUtils.checkRequired(
Expand Down Expand Up @@ -308,6 +312,7 @@ public DeleteReplicaPropCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {
CollectionHandlingUtils.checkRequired(
Expand Down Expand Up @@ -336,6 +341,7 @@ public BalanceShardsUniqueCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {
if (StringUtils.isBlank(message.getStr(COLLECTION_PROP))
Expand Down Expand Up @@ -371,6 +377,7 @@ public ModifyCollectionCmd(CollectionCommandContext ccc) {
this.ccc = ccc;
}

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Object> results)
throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void offerStateUpdate(byte[] data) throws KeeperException, InterruptedExc
ocmh.overseer.offerStateUpdate(data);
}

@Override
public void offerStateUpdate(MapWriter mw) throws KeeperException, InterruptedException {
ocmh.overseer.offerStateUpdate(mw);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public NodeMetricImpl(String key, Function<Object, T> converter) {
this.registry = Registry.UNSPECIFIED;
}

@Override
public Registry getRegistry() {
return registry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public PlacementPluginAssignStrategy(PlacementPlugin plugin) {
this.plugin = plugin;
}

@Override
public List<ReplicaPosition> assign(
SolrCloudManager solrCloudManager, List<Assign.AssignRequest> assignRequests)
throws Assign.AssignmentException, IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public Set<Node> getLiveNodes() {
return liveNodes;
}

@Override
public Set<Node> getLiveDataNodes() {
return liveNodesWithData;
}
Expand Down Expand Up @@ -132,6 +133,7 @@ public String toString() {
* comparing node names given that new instances of {@link Node} are created with names equal to
* existing instances (See {@link ReplicaImpl} constructor).
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
Expand All @@ -146,6 +148,7 @@ public boolean equals(Object obj) {
return Objects.equals(this.nodeName, other.nodeName);
}

@Override
public int hashCode() {
return Objects.hashCode(nodeName);
}
Expand Down Expand Up @@ -300,6 +303,7 @@ public ShardState getState() {
return shardState;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
Expand All @@ -318,6 +322,7 @@ public boolean equals(Object obj) {
&& Objects.equals(this.leader, other.leader);
}

@Override
public int hashCode() {
return Objects.hash(shardName, collection, shardState);
}
Expand Down Expand Up @@ -461,6 +466,7 @@ static org.apache.solr.common.cloud.Replica.Type toCloudReplicaType(ReplicaType
}
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
Expand All @@ -480,6 +486,7 @@ public boolean equals(Object obj) {
&& Objects.equals(this.node, other.node);
}

@Override
public int hashCode() {
return Objects.hash(replicaName, coreName, shard, replicaType, replicaState, node);
}
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/core/CoreSorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ CoreSorter init(CoreContainer cc, Collection<CoreDescriptor> coreDescriptors) {
return this;
}

@Override
public int compare(CoreDescriptor cd1, CoreDescriptor cd2) {
String s1 = getShardName(cd1.getCloudDescriptor());
String s2 = getShardName(cd2.getCloudDescriptor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public boolean exists(String path) throws IOException {
}
}

@Override
public boolean isPersistent() {
return false;
}
Expand All @@ -64,6 +65,7 @@ public void remove(String path) throws IOException {
// ram dir does not persist its dir anywhere
}

@Override
public void cleanupOldIndexDirectories(
final String dataDirPath, final String currentIndexDirPath, boolean reload) {
// currently a no-op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void deleteFilesFromConfig(String configName, List<String> filesToDelete)
throw new UnsupportedOperationException();
}

@Override
public void copyConfig(String fromConfig, String toConfig) throws IOException {
throw new UnsupportedOperationException();
}
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/core/PluginBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ public Optional<T> getInstance() {
return Optional.ofNullable(inst);
}

@Override
public T get() {
return inst;
}
Expand Down Expand Up @@ -435,6 +436,7 @@ public PluginInfo getPluginInfo() {
return pluginInfo;
}

@Override
public String toString() {
return String.valueOf(inst);
}
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/core/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public PluginInfo getChild(String type) {
return l.isEmpty() ? null : l.get(0);
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Object> toMap(Map<String, Object> map) {
map.putAll(attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public CommitsLoggingInfo(List<? extends IndexCommit> commits) {
this.commits = commits;
}

@Override
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append("num=").append(commits.size());
Expand Down Expand Up @@ -128,6 +129,7 @@ public CommitsLoggingDebug(List<? extends IndexCommit> commits) {
super(commits);
}

@Override
protected void appendDetails(StringBuilder sb, IndexCommit c) {
super.appendDetails(sb, c);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ public <T> T newInstance(String name, Class<T> expectedType) {
private static final Class<?>[] NO_CLASSES = new Class<?>[0];
private static final Object[] NO_OBJECTS = new Object[0];

@Override
public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
return newInstance(cname, expectedType, subpackages, NO_CLASSES, NO_OBJECTS);
}
Expand Down Expand Up @@ -711,6 +712,7 @@ protected void doReloadAction(Ctx ctx) {
}

/** Tell all {@link SolrCoreAware} instances about the SolrCore */
@Override
public void inform(SolrCore core) {
if (getSchemaLoader() != null) core.getPackageListeners().addListener(schemaLoader);

Expand Down
Loading

0 comments on commit 5465b01

Please sign in to comment.