From 52b85571886fa09c112fd4f6e0a79c8bd19161c0 Mon Sep 17 00:00:00 2001 From: Tglman Date: Tue, 24 Oct 2023 10:53:25 +0100 Subject: [PATCH] fix: avoid storage to go in read only mode if index key type validation fails --- .../impl/local/OAbstractPaginatedStorage.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java index a3d31a348e5..9d938de5920 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java @@ -2779,6 +2779,22 @@ public int addIndexEngine( throw new OIndexException("Types of indexed keys have to be provided"); } + final OBinarySerializer keySerializer = determineKeySerializer(indexDefinition); + if (keySerializer == null) { + throw new OIndexException("Can not determine key serializer"); + } + + final int keySize = determineKeySize(indexDefinition); + + final boolean nullValuesSupport = !indexDefinition.isNullValuesIgnored(); + final byte serializerId; + + if (valueSerializer != null) { + serializerId = valueSerializer.getId(); + } else { + serializerId = -1; + } + checkBackupRunning(); stateLock.writeLock().lock(); try { @@ -2806,22 +2822,6 @@ public int addIndexEngine( } } - final OBinarySerializer keySerializer = determineKeySerializer(indexDefinition); - if (keySerializer == null) { - throw new OIndexException("Can not determine key serializer"); - } - - final int keySize = determineKeySize(indexDefinition); - - final boolean nullValuesSupport = !indexDefinition.isNullValuesIgnored(); - final byte serializerId; - - if (valueSerializer != null) { - serializerId = valueSerializer.getId(); - } else { - serializerId = -1; - } - final OBaseIndexEngine engine = addIndexEngineInternal( atomicOperation,