Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/PR#4604-update-google-errorprone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: Update com.google.errorprone to 2.50.0 and suppress new bug patterns (ReferenceEquality, JdkObsolete, NotJavadoc, TypeParameterQualifier)
type: other
authors:
- name: Jan Høydahl
links:
- name: PR#4604
url: https://github.com/apache/solr/pull/4604
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ google-api-grpc-proto = "2.61.1"
# @keep for version alignment
google-autovalue = "1.11.1"
google-cloud-bom = "0.265.0"
google-errorprone = "2.41.0"
google-errorprone = "2.50.0"
# @keep for version alignment
google-gson = "2.14.0"
google-guava = "33.6.0-jre"
Expand Down
11 changes: 5 additions & 6 deletions solr/api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,errorprone
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto.value:auto-value-annotations:1.11.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto:auto-common:1.2.2=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.47.0=jarValidation,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_check_api:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.27.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.50.0=annotationProcessor,errorprone,jarValidation,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_check_api:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.guava:failureaccess:1.0.3=annotationProcessor,errorprone,jarValidation,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:33.6.0-jre=annotationProcessor,errorprone,jarValidation,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,errorprone,jarValidation,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
Expand Down
11 changes: 5 additions & 6 deletions solr/benchmark/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,errorprone
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto.value:auto-value-annotations:1.11.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto:auto-common:1.2.2=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.47.0=compileClasspath,jarValidation,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_check_api:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.27.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.50.0=annotationProcessor,compileClasspath,errorprone,jarValidation,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_check_api:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.guava:failureaccess:1.0.3=annotationProcessor,compileClasspath,errorprone,jarValidation,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:33.6.0-jre=annotationProcessor,compileClasspath,errorprone,jarValidation,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,compileClasspath,errorprone,jarValidation,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
Expand Down
11 changes: 5 additions & 6 deletions solr/core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ com.github.stephenc.jcip:jcip-annotations:1.0-1=compileClasspath,compileClasspat
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto.value:auto-value-annotations:1.11.1=annotationProcessor,errorprone,testAnnotationProcessor
com.google.auto:auto-common:1.2.2=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.47.0=compileClasspath,compileClasspathCopy,jarValidation,runtimeClasspath,runtimeClasspathCopy,runtimeLibs,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_check_api:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.41.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.27.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotation:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.50.0=annotationProcessor,compileClasspath,compileClasspathCopy,errorprone,jarValidation,runtimeClasspath,runtimeClasspathCopy,runtimeLibs,testAnnotationProcessor,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
com.google.errorprone:error_prone_check_api:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.50.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,errorprone,testAnnotationProcessor
com.google.guava:failureaccess:1.0.3=annotationProcessor,compileClasspath,compileClasspathCopy,errorprone,jarValidation,runtimeClasspath,runtimeClasspathCopy,runtimeLibs,testAnnotationProcessor,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
com.google.guava:guava:33.6.0-jre=annotationProcessor,compileClasspath,compileClasspathCopy,errorprone,jarValidation,runtimeClasspath,runtimeClasspathCopy,runtimeLibs,testAnnotationProcessor,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,compileClasspath,compileClasspathCopy,errorprone,jarValidation,runtimeClasspath,runtimeClasspathCopy,runtimeLibs,testAnnotationProcessor,testCompileClasspath,testCompileClasspathCopy,testRuntimeClasspath,testRuntimeClasspathCopy
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/cli/ExportTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ private void addProducers(Map<String, Slice> m) {
}
}

// EOFDOC is a unique sentinel instance, so identity comparison against it is intentional
@SuppressWarnings("ReferenceEquality")
private void addConsumer(CountDownLatch consumerlatch) {
consumerThreadpool.execute(
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ public boolean isCollectionCreation() {
return isCollectionCreation;
}

// ZkStateWriter.NO_OP is a unique sentinel, so identity comparison against it is intentional
@Override
@SuppressWarnings("ReferenceEquality")
public void computeUpdates(ClusterState clusterState, SolrZkClient client) {
boolean hasJsonUpdates = false;
List<PerReplicaStatesOps> perReplicaStateOps = new ArrayList<>();
Expand Down Expand Up @@ -911,7 +913,9 @@ public boolean isCollectionCreation() {
return false;
}

// ZkStateWriter.NO_OP is a unique sentinel, so identity comparison against it is intentional
@Override
@SuppressWarnings("ReferenceEquality")
public void computeUpdates(ClusterState clusterState, SolrZkClient client) {
final DocCollection docCollection = clusterState.getCollectionOrNull(collectionName);
Optional<ZkWriteCommand> result =
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/cloud/LockTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ boolean isLocked() {
return false;
}

// checks that the exact lock instance held by this node is the one being released
@SuppressWarnings("ReferenceEquality")
boolean unlock(LockImpl lockObject) {
if (--refCount > 0) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/cloud/Overseer.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ public synchronized void start(String id) {
assert ObjectReleaseTracker.track(this);
}

/** Start {@link ClusterSingleton} plugins when we become the leader. */
// Start ClusterSingleton plugins when we become the leader.

/** Stop {@link ClusterSingleton} plugins when we lose leadership. */
// Stop ClusterSingleton plugins when we lose leadership.
public Stats getStats() {
return stats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public ReplicateFromLeader(CoreContainer cc, String coreName) {
* @param switchTransactionLog if true, ReplicationHandler will rotate the transaction log once
* the replication is done
*/
// INDEX_FETCH_SUCCESS is a unique sentinel instance, so identity comparison is intentional
@SuppressWarnings("ReferenceEquality")
public void startReplication(boolean switchTransactionLog) {
try (SolrCore core = cc.getCore(coreName)) {
if (core == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public class CategoryRoutedAlias extends RoutedAlias {
this.mustMatch = mustMatch == null ? null : compileMustMatch(mustMatch);
}

// Aliases is an immutable snapshot; identity comparison detects whether ZK handed us a new one
@SuppressWarnings("ReferenceEquality")
@Override
public boolean updateParsedCollectionAliases(ZkStateReader zkStateReader, boolean contextualize) {
final Aliases aliases =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ protected String getHeadCollectionIfOrdered(AddUpdateCommand cmd) {
* @param targetCol the collection for which a document is destined.
* @return A list of actions across the DRA.
*/
// sourceAlias is compared against the very dimension instance it came from; identity intended
@SuppressWarnings("ReferenceEquality")
@Override
protected List<Action> calculateActions(String targetCol) {
String[] routeValues = SEP_MATCHER.split(targetCol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ private static void checkMillis(Instant date) {
}
}

// Aliases is immutable and replaced wholesale on change, so identity comparison detects updates
@Override
@SuppressWarnings("ReferenceEquality")
public boolean updateParsedCollectionAliases(ZkStateReader zkStateReader, boolean contextualize) {
final Aliases aliases = zkStateReader.getAliases();
if (this.parsedCollectionsAliases != aliases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public void updateClusterState(Function<ClusterState, ClusterState> fun) {
* a {@link org.apache.zookeeper.KeeperException.BadVersionException} this instance becomes
* unusable and must be discarded
*/
// NO_OP is a unique sentinel, so identity comparison against it is intentional
@SuppressWarnings("ReferenceEquality")
public ClusterState enqueueUpdate(
ClusterState prevState, List<ZkWriteCommand> cmds, ZkWriteCallback callback)
throws IllegalStateException, Exception {
Expand Down Expand Up @@ -189,6 +191,8 @@ public ClusterState enqueueUpdate(
return clusterState;
}

// NO_OP is a unique sentinel, so identity comparison against it is intentional
@SuppressWarnings("ReferenceEquality")
private boolean isNoOps(List<ZkWriteCommand> cmds) {
for (ZkWriteCommand cmd : cmds) {
if (cmd != NO_OP) return false;
Expand Down Expand Up @@ -229,6 +233,9 @@ public ClusterState writePendingUpdates() throws KeeperException, InterruptedExc
* @throws KeeperException if any ZooKeeper operation results in an error
* @throws InterruptedException if the current thread is interrupted
*/
// Identity comparison of the updates map against this.updates is intentional: it detects
// whether the caller asked to flush all pending updates rather than a specific subset
@SuppressWarnings("ReferenceEquality")
public ClusterState writePendingUpdates(
Map<String, ZkWriteCommand> updates, boolean resetPendingUpdateCounters)
throws IllegalStateException, KeeperException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public ZkWriteCommand(String name, DocCollection collection) {
this(name, collection, null, true);
}

// NO_OP is a unique sentinel, so identity comparison against it is intentional
@Override
@SuppressWarnings("ReferenceEquality")
public String toString() {
return getClass().getSimpleName() + ": " + (this == NO_OP ? "no-op" : name + "=" + collection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ private void removeFromCache(CacheValue v) {

// be sure the method is called with the sync lock on this object
// returns true if we closed the cacheValue, false if it will be closed later
// CacheValue entries are cached per instance, so identity comparison is intentional
@SuppressWarnings("ReferenceEquality")
private boolean closeCacheValue(CacheValue cacheValue, Set<CacheValue> deferRemove) {
log.debug("looking to close {} {}", cacheValue.path, cacheValue.closeEntries);
List<CloseListener> listeners = closeListeners.remove(cacheValue.directory);
Expand Down Expand Up @@ -300,6 +302,8 @@ private static Iterable<CacheValue> sorted(Set<CacheValue> vals) {
return vals.stream().sorted((a, b) -> b.path.compareTo(a.path)).collect(Collectors.toList());
}

// CacheValue entries are cached per instance, so identity comparison is intentional
@SuppressWarnings("ReferenceEquality")
private boolean maybeDeferClose(CacheValue maybeDefer) {
assert maybeDefer.deleteOnClose;
for (CacheValue maybeChildPath : byPathCache.values()) {
Expand Down Expand Up @@ -381,6 +385,8 @@ public boolean exists(String path) throws IOException {
* java.lang.String, boolean)
*/
@Override
// checking whether filterDirectory() returned the same instance is intentional
@SuppressWarnings("ReferenceEquality")
public final Directory get(String path, DirContext dirContext, String rawLockType)
throws IOException {
String fullPath = normalize(path);
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ public CoreSorter getCoreSorter() {
return coreSorter;
}

// checking whether putCore() returned the same core instance is intentional
@SuppressWarnings("ReferenceEquality")
protected SolrCore registerCore(
CoreDescriptor cd, SolrCore core, boolean registerInZk, boolean skipRecovery) {
if (core == null) {
Expand Down
3 changes: 2 additions & 1 deletion solr/core/src/java/org/apache/solr/core/PluginBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public T put(String name, T plugin) {
return old == null ? null : old.get();
}

@SuppressWarnings({"unchecked"})
// checking whether the registry already held this exact plugin instance is intentional
@SuppressWarnings({"unchecked", "ReferenceEquality"})
public PluginHolder<T> put(String name, PluginHolder<T> plugin) {
Boolean registerApi = null; // i.e. register for V2
Boolean disableV1 = null; // i.e. do *not* register for v1
Expand Down
7 changes: 7 additions & 0 deletions solr/core/src/java/org/apache/solr/core/SolrCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,8 @@ public RefCounted<SolrIndexSearcher> getSearcher(
*
* <p>This method acquires openSearcherLock - do not call with searchLock held!
*/
// comparing schema instances detects a schema reload, so identity comparison is intentional
@SuppressWarnings("ReferenceEquality")
public RefCounted<SolrIndexSearcher> openNewSearcher(
boolean updateHandlerReopens, boolean realtime) {
if (isClosed()) { // catch some errors quicker
Expand Down Expand Up @@ -2532,6 +2534,9 @@ public RefCounted<SolrIndexSearcher> openNewSearcher(
* SolrIndexSearcher}.
*/
// TODO waitSearcher should be an AtomicReference or something that is a more clear API
// comparing searcher instances detects whether the underlying searcher changed, so identity
// comparison is intentional
@SuppressWarnings("ReferenceEquality")
public RefCounted<SolrIndexSearcher> getSearcher(
boolean forceNew,
boolean returnSearcher,
Expand Down Expand Up @@ -2818,6 +2823,8 @@ public boolean isReloaded() {
//
// onDeckSearchers will also be decremented (it should have been incremented
// as a result of opening a new searcher).
// detecting re-registration of the same searcher holder instance is intentional
@SuppressWarnings("ReferenceEquality")
private void registerSearcher(RefCounted<SolrIndexSearcher> newSearcherHolder) {
synchronized (searcherLock) {
try {
Expand Down
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/core/SolrPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public AllowPathBuilder addPath(String path) {
* Adds an allowed path. Detects "_ALL_" which means all paths are allowed. Does not detect "*"
* (not supported as a {@link Path} on Windows), see {@link #addPath(String)}.
*/
// ALL_PATHS is a unique sentinel, so identity comparison against it is intentional
@SuppressWarnings("ReferenceEquality")
public AllowPathBuilder addPath(Path path) {
if (path == null) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public SolrResourceLoader(Path instanceDir, ClassLoader parent) {
*
* @param urls the URLs of files to add
*/
// checking whether addURLsToClassLoader() returned the same instance is intentional
@SuppressWarnings("ReferenceEquality")
synchronized void addToClassLoader(List<URL> urls) {
URLClassLoader newLoader = addURLsToClassLoader(classLoader, urls);
if (newLoader == classLoader) {
Expand Down Expand Up @@ -484,6 +486,9 @@ public <T> Class<? extends T> findClass(String cname, Class<T> expectedType) {
* @param subpackages the packages to be tried if the cname starts with solr.
* @return the loaded class. An exception is thrown if it fails
*/
// comparing against the default `packages` array and the webapp classloader by identity is
// intentional
@SuppressWarnings("ReferenceEquality")
public <T> Class<? extends T> findClass(
String cname, Class<T> expectedType, String... subpackages) {
if (subpackages == null || subpackages.length == 0 || subpackages == packages) {
Expand Down Expand Up @@ -695,13 +700,17 @@ public <T> boolean addToCoreAware(T obj) {
}
}

// enforcing that the loader stays bound to the same SolrConfig instance is intentional
@SuppressWarnings("ReferenceEquality")
protected final void setSolrConfig(SolrConfig config) {
if (this.config != null && this.config != config) {
throw new IllegalStateException("SolrConfig instance is already associated with this loader");
}
this.config = config;
}

// enforcing that the loader stays bound to the same CoreContainer instance is intentional
@SuppressWarnings("ReferenceEquality")
protected final void setCoreContainer(CoreContainer coreContainer) {
if (this.coreContainer != null && this.coreContainer != coreContainer) {
throw new IllegalStateException(
Expand Down
Loading
Loading