Skip to content

Commit 0234b14

Browse files
committed
Use VLong for byte serialization
1 parent c7b481c commit 0234b14

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

server/src/main/java/org/elasticsearch/common/blobstore/BlobStoreActionStats.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public record BlobStoreActionStats(long operations, long requests) implements Wr
2828
public static final BlobStoreActionStats ZERO = new BlobStoreActionStats(0, 0);
2929

3030
public BlobStoreActionStats(StreamInput in) throws IOException {
31-
this(in.readLong(), in.readLong());
31+
this(in.readVLong(), in.readVLong());
3232
}
3333

3434
public BlobStoreActionStats {
@@ -38,8 +38,8 @@ public BlobStoreActionStats(StreamInput in) throws IOException {
3838

3939
@Override
4040
public void writeTo(StreamOutput out) throws IOException {
41-
out.writeLong(operations);
42-
out.writeLong(requests);
41+
out.writeVLong(operations);
42+
out.writeVLong(requests);
4343
}
4444

4545
public BlobStoreActionStats add(BlobStoreActionStats other) {

server/src/test/java/org/elasticsearch/common/blobstore/BlobStoreActionStatsTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import org.elasticsearch.test.ESTestCase;
1313

14+
import java.io.IOException;
15+
1416
public class BlobStoreActionStatsTests extends ESTestCase {
1517

1618
public void testAdd() {
@@ -37,6 +39,13 @@ public void testIsZero() {
3739
assertFalse(randomBlobStoreActionStats(1, Long.MAX_VALUE).isZero());
3840
}
3941

42+
public void testSerialization() throws IOException {
43+
final BlobStoreActionStats original = randomBlobStoreActionStats(Long.MAX_VALUE);
44+
BlobStoreActionStats deserializedModel = copyWriteable(original, null, BlobStoreActionStats::new);
45+
assertEquals(original, deserializedModel);
46+
assertNotSame(original, deserializedModel);
47+
}
48+
4049
private BlobStoreActionStats randomBlobStoreActionStats(long upperBound) {
4150
return randomBlobStoreActionStats(0, upperBound);
4251
}

0 commit comments

Comments
 (0)