SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix java.lang.IllegalArgumentException: Comparison method violates its general contract! (#6239)
fo40225008ac38ebcc4
diff --git a/other/java/client/src/main/java/seaweedfs/client/ReadChunks.java b/other/java/client/src/main/java/seaweedfs/client/ReadChunks.javaindex e563c0ccc3..18826dd48d 100644--- a/other/java/client/src/main/java/seaweedfs/client/ReadChunks.java+++ b/other/java/client/src/main/java/seaweedfs/client/ReadChunks.java@@ -14,20 +14,23 @@ public class ReadChunks {points.add(new Point(chunk.getOffset(), chunk, true));points.add(new Point(chunk.getOffset() + chunk.getSize(), chunk, false));}+Collections.sort(points, new Comparator<Point>() {@Overridepublic int compare(Point a, Point b) {- int x = (int) (a.x - b.x);- if (a.x != b.x) {- return (int) (a.x - b.x);- }- if (a.ts != b.ts) {- return (int) (a.ts - b.ts);+ int xComparison = Long.compare(a.x, b.x);+ if (xComparison != 0) {+ return xComparison;}- if (!a.isStart) {- return -1;++ // If x values are equal, compare ts+ int tsComparison = Long.compare(a.ts, b.ts);+ if (tsComparison != 0) {+ return tsComparison;}- return 1;++ // If both x and ts are equal, prioritize start points+ return Boolean.compare(b.isStart, a.isStart); // b.isStart first to prioritize starts}});