Skip to content

Commit

Permalink
Fix equals/hashcode of IOContext (#13204)
Browse files Browse the repository at this point in the history
  • Loading branch information
uschindler committed Mar 23, 2024
1 parent 6d908b8 commit 31d1099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Bug Fixes

* GITHUB#13169: Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue (Ben Trent)

* GITHUB#13204: Fix euals/hashCode of IOContext. (Uwe Schindler, Robert Muir)

Other
---------------------

Expand Down
19 changes: 6 additions & 13 deletions lucene/core/src/java/org/apache/lucene/store/IOContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.lucene.store;

import java.util.Objects;

/**
* IOContext holds additional details on the merge/search context. A IOContext object can never be
* initialized as null as passed as a parameter to either {@link
Expand Down Expand Up @@ -118,13 +120,7 @@ public IOContext(IOContext ctxt, boolean readOnce) {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((context == null) ? 0 : context.hashCode());
result = prime * result + ((flushInfo == null) ? 0 : flushInfo.hashCode());
result = prime * result + ((mergeInfo == null) ? 0 : mergeInfo.hashCode());
result = prime * result + (readOnce ? 1231 : 1237);
return result;
return Objects.hash(context, flushInfo, mergeInfo, readOnce, load);
}

@Override
Expand All @@ -134,13 +130,10 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass()) return false;
IOContext other = (IOContext) obj;
if (context != other.context) return false;
if (flushInfo == null) {
if (other.flushInfo != null) return false;
} else if (!flushInfo.equals(other.flushInfo)) return false;
if (mergeInfo == null) {
if (other.mergeInfo != null) return false;
} else if (!mergeInfo.equals(other.mergeInfo)) return false;
if (!Objects.equals(flushInfo, other.flushInfo)) return false;
if (!Objects.equals(mergeInfo, other.mergeInfo)) return false;
if (readOnce != other.readOnce) return false;
if (load != other.load) return false;
return true;
}

Expand Down

0 comments on commit 31d1099

Please sign in to comment.