Skip to content

Commit

Permalink
fix(issue2140): remove override equals and hashCode method for Object…
Browse files Browse the repository at this point in the history
…Reader (#2147)

close #2140

Signed-off-by: Shichao Nie <[email protected]>
  • Loading branch information
SCNieh authored Nov 8, 2024
1 parent a74cf69 commit 351e1e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,14 @@ public synchronized void close0() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CompositeObjectReader reader = (CompositeObjectReader) o;
return Objects.equals(objectMetadata.objectId(), reader.objectMetadata.objectId());
// NOTE: DO NOT OVERRIDE THIS
return super.equals(o);
}

@Override
public int hashCode() {
return Objects.hashCode(objectMetadata.objectId());
// NOTE: DO NOT OVERRIDE THIS
return super.hashCode();
}

private void asyncGetBasicObjectInfo(CompletableFuture<BasicObjectInfo> basicObjectInfoCf) {
Expand Down
11 changes: 4 additions & 7 deletions s3stream/src/main/java/com/automq/stream/s3/ObjectReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,14 @@ public synchronized void close0() {

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
DefaultObjectReader reader = (DefaultObjectReader) o;
return Objects.equals(metadata.objectId(), reader.metadata.objectId());
// NOTE: DO NOT OVERRIDE THIS
return super.equals(o);
}

@Override
public int hashCode() {
return Objects.hash(metadata.objectId());
// NOTE: DO NOT OVERRIDE THIS
return super.hashCode();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* An asynchronous LRU cache that supports asynchronous value computation.
*
* @param <K> key type
* @param <V> value type, NOTE: V must not override equals and hashCode
*/
public class AsyncLRUCache<K, V extends AsyncMeasurable> {
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncLRUCache.class);
private final AsyncLRUCacheStats stats = AsyncLRUCacheStats.getInstance();
Expand Down

0 comments on commit 351e1e0

Please sign in to comment.