diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCacheEntry.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCacheEntry.java index 8bf60773c..04bb68dba 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCacheEntry.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCacheEntry.java @@ -296,7 +296,7 @@ public class LRUMediaCacheEntry { } } // 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);