[cache] Fix concurrent use of a cache entry (#3785)
Closes #3507 Fix some rare case where the concurrent readings of a cache entry can fail. Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>pull/3789/head
parent
e765af06cb
commit
3ddbdb25ed
|
@ -296,7 +296,7 @@ public class LRUMediaCacheEntry<V> {
|
|||
}
|
||||
}
|
||||
// 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);
|
||||
|
|
Loading…
Reference in New Issue