Skip to content
Merged
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#4605-reference-equality-fixes.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: Fix reference-equality comparison bugs in ZkMaintenanceUtils single-file upload and HttpShardHandler onlyNrt detection
type: fixed
authors:
- name: Jan Høydahl
links:
- name: PR#4605
url: https://github.com/apache/solr/pull/4605
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void prepDistributed(ResponseBuilder rb) {

ReplicaSource replicaSource;
if (zkController != null) {
boolean onlyNrt = Boolean.TRUE == req.getContext().get(ONLY_NRT_REPLICAS);
boolean onlyNrt = Boolean.TRUE.equals(req.getContext().get(ONLY_NRT_REPLICAS));

replicaSource =
new CloudReplicaSource.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public void testSetHighestTerms() throws Exception {
private <T> void waitFor(T expected, Supplier<T> supplier) throws InterruptedException {
TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS, new TimeSource.CurrentTimeSource());
while (!timeOut.hasTimedOut()) {
if (expected == supplier.get()) return;
if (Objects.equals(expected, supplier.get())) return;
Thread.sleep(100);
}
assertEquals(expected, supplier.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
if (file.getFileName().toString().equals(ZKNODE_DATA_FILE)
&& zkClient.exists(zkNode)) {
zkClient.setData(zkNode, file);
} else if (file == rootPath) {
} else if (file.equals(rootPath)) {
// We are only uploading a single file, preVisitDirectory was never called
if (zkClient.exists(zkPath)) {
zkClient.setData(zkPath, file);
Expand Down
2 changes: 2 additions & 0 deletions solr/solrj/src/java/org/apache/solr/common/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ private static List<FieldWriter> getReflectData(
Class<? extends Annotation> catchAllAnnotation,
Function<Field, String> fieldNamer)
throws IllegalAccessException {
// ClassLoader identity (not equals) determines whether it is safe to cache reflective metadata.
@SuppressWarnings("ReferenceEquality")
boolean sameClassLoader = c.getClassLoader() == Utils.class.getClassLoader();
// we should not cache the class references of objects loaded from packages because they will
// not get garbage collected
Expand Down
Loading