Skip to content

Commit

Permalink
[cache] Fix concurrent use of a cache entry (#3785)
Browse files Browse the repository at this point in the history
Closes #3507
Fix some rare case where the concurrent readings of a cache entry can fail.

Signed-off-by: Gwendal Roulleau <[email protected]>
  • Loading branch information
dalgwen authored Aug 30, 2023
1 parent e765af0 commit 3ddbdb2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ protected byte[] read(int start, int sizeToRead) throws IOException {
}
}
// the cache file is now filled, get bytes from it.
long maxToRead = Math.min(currentSize, sizeToRead);
long maxToRead = Math.min(fileChannelLocal.size(), sizeToRead);
ByteBuffer byteBufferFromChannelFile = ByteBuffer.allocate((int) maxToRead);
int byteReadNumber = fileChannelLocal.read(byteBufferFromChannelFile, Integer.valueOf(start).longValue());
logger.trace("Read {} bytes from the filechannel", byteReadNumber);
Expand Down

0 comments on commit 3ddbdb2

Please sign in to comment.