This is an automated email from the ASF dual-hosted git repository. adulceanu pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push: new 9e56920b14 OAK-10345 - Add debug log message if larger blob is compared byte-wise. (#1024) 9e56920b14 is described below commit 9e56920b145ecd08369603d24895f4438c817c6f Author: Axel Hanikel <ahani...@gmail.com> AuthorDate: Fri Jul 14 13:27:29 2023 +0200 OAK-10345 - Add debug log message if larger blob is compared byte-wise. (#1024) * OAK-10345 - Add debug log message if larger blob is compared byte-wise. * OAK-10345 - Add an enable switch to make this as cheap as possible. * OAK-10345 - Use SystemPropertySupplier for system properties. --------- Co-authored-by: Axel Hanikel <ahani...@adobe.com> --- .../jackrabbit/oak/plugins/memory/AbstractBlob.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java index 6415a3d269..59beb49670 100644 --- a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java +++ b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java @@ -26,8 +26,11 @@ import org.apache.jackrabbit.guava.common.hash.Hashing; import org.apache.jackrabbit.guava.common.io.ByteSource; import org.apache.jackrabbit.oak.api.Blob; +import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Abstract base class for {@link Blob} implementations. @@ -36,6 +39,20 @@ import org.jetbrains.annotations.Nullable; */ public abstract class AbstractBlob implements Blob { + private static final Logger LOG = LoggerFactory.getLogger(AbstractBlob.class); + + private static final boolean DEBUG_BLOB_EQUAL_LOG = SystemPropertySupplier + .create("oak.abstractblob.equal.log", false) + .loggingTo(LOG) + .formatSetMessage( (name, value) -> String.format("%s set to: %s", name, value) ) + .get(); + + private static final long DEBUG_BLOB_EQUAL_LOG_LIMIT = SystemPropertySupplier + .create("oak.abstractblob.equal.log.limit", 100_000_000L) + .loggingTo(LOG) + .formatSetMessage( (name, value) -> String.format("%s set to: %s", name, value) ) + .get(); + private static ByteSource supplier(final Blob blob) { return new ByteSource() { @Override @@ -62,6 +79,10 @@ public abstract class AbstractBlob implements Blob { return true; } + if (DEBUG_BLOB_EQUAL_LOG && al > DEBUG_BLOB_EQUAL_LOG_LIMIT) { + LOG.debug("Blobs have the same length of {} and we're falling back to byte-wise comparison.", al); + } + try { return supplier(a).contentEquals(supplier(b)); } catch (IOException e) {