diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree/BTree.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree/BTree.java index bcf91f5139..b297d940ea 100644 --- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree/BTree.java +++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree/BTree.java @@ -25,6 +25,7 @@ import org.eclipse.rdf4j.common.io.ByteArrayUtil; import org.eclipse.rdf4j.common.io.NioFile; import org.eclipse.rdf4j.sail.SailException; +import org.eclipse.rdf4j.sail.nativerdf.NativeStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -292,9 +293,10 @@ public BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize, this.valueSize = buf.getInt(); this.rootNodeID = buf.getInt(); - if (rootNodeID == 0) { - if (nioFile.size() >= 1024) { - throw new IllegalStateException("Root node ID is 0 but file is not empty"); + if (rootNodeID == 0 && NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) { + if (nioFile.size() > blockSize) { + throw new SailException("Root node ID is 0 but file is not empty. Btree may be corrupt. File: " + + file.getAbsolutePath()); } }