From 187274071f0c6f5267da6a71a76539ebc2a4d0ae Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 2 Jun 2021 13:21:07 +0200 Subject: [PATCH] Bugfix --- .../dbengine/database/disk/LLLocalDictionary.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java index 62eff79..dbb827f 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalDictionary.java @@ -574,9 +574,14 @@ public class LLLocalDictionary implements LLDictionary { ByteBuf prevDataToSendToUpdater = prevData == null ? null : prevData.retainedSlice(); try { newData = updater.apply(prevDataToSendToUpdater == null ? null : prevDataToSendToUpdater.retain()); - assert prevDataToSendToUpdater == null + if (!(prevDataToSendToUpdater == null || prevDataToSendToUpdater.readerIndex() == 0 - || !prevDataToSendToUpdater.isReadable(); + || !prevDataToSendToUpdater.isReadable())) { + throw new IllegalStateException("The updater has read the previous data partially" + + " (read bytes: " + prevDataToSendToUpdater.readerIndex() + + " unread bytes: " + prevDataToSendToUpdater.readableBytes() + ")." + + " The only allowed options are reading the data fully or not reading it at all"); + } } finally { if (prevDataToSendToUpdater != null) { prevDataToSendToUpdater.release();