diff --git a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreBackedInputStreamImpl.java b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreBackedInputStreamImpl.java index e3fc68ab7e218..c5fda387c73f6 100644 --- a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreBackedInputStreamImpl.java +++ b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreBackedInputStreamImpl.java @@ -144,6 +144,7 @@ public void close() { @Override public int available() throws IOException { - return (int)(objectLen - cursor) + buffer.readableBytes(); + long available = objectLen - cursor + buffer.readableBytes(); + return available > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) available; } }