From 769292d09ab9210a04a2a0cd96f1b8a71b879fcf Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 2 May 2024 14:13:20 -0600 Subject: [PATCH] Fix --- .../org/elasticsearch/blobcache/shared/SharedBytes.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBytes.java b/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBytes.java index e24a0520e5636..334a6733c5de0 100644 --- a/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBytes.java +++ b/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBytes.java @@ -204,12 +204,13 @@ public static int copyToCacheFileAligned(IO fc, InputStream input, int fileChann if (bytesRead <= 0) { break; } - bytesCopied = copyToCacheFileAligned(fc, fileChannelPos + bytesCopied, progressUpdater, buffer); + bytesCopied += copyToCacheFileAligned(fc, fileChannelPos + bytesCopied, buffer); + progressUpdater.accept(bytesCopied); } return bytesCopied; } - public static int copyToCacheFileAligned(IO fc, int fileChannelPos, IntConsumer progressUpdater, ByteBuffer buffer) + public static int copyToCacheFileAligned(IO fc, int fileChannelPos, ByteBuffer buffer) throws IOException { if (buffer.hasRemaining()) { // ensure that last write is aligned on 4k boundaries (= page size) @@ -218,7 +219,6 @@ public static int copyToCacheFileAligned(IO fc, int fileChannelPos, IntConsumer buffer.position(buffer.position() + adjustment); } int bytesCopied = positionalWrite(fc, fileChannelPos, buffer); - progressUpdater.accept(bytesCopied); return bytesCopied; }