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 8bf60773cc8..04bb68dba93 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 @@ 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);