diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java index 419527cce..f99040400 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java @@ -304,11 +304,10 @@ public void insertAll(Iterable documents) { documents.forEach(document -> batchWriteDataList.add(getBatchWriteForInsert(document))); List batchWriteRecords = batchWriteDataList.stream().map(BatchWriteData::batchRecord).toList(); - RuntimeException re = null; try { client.operate(null, batchWriteRecords); } catch (AerospikeException e) { - re = translateError(e); + throw translateError(e); } checkForErrorsAndUpdateVersion(batchWriteDataList, batchWriteRecords, "insert"); @@ -361,11 +360,10 @@ public void updateAll(Iterable documents) { documents.forEach(document -> batchWriteDataList.add(getBatchWriteForUpdate(document))); List batchWriteRecords = batchWriteDataList.stream().map(BatchWriteData::batchRecord).toList(); - RuntimeException re = null; try { client.operate(null, batchWriteRecords); } catch (AerospikeException e) { - re = translateError(e); + throw translateError(e); } checkForErrorsAndUpdateVersion(batchWriteDataList, batchWriteRecords, "update"); diff --git a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java index acfad3f82..4d555a6da 100644 --- a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java @@ -425,5 +425,4 @@ public BatchWriteData getBatchWriteForUpdate(T document) { protected boolean batchRecordFailed(BatchRecord batchRecord) { return batchRecord.resultCode != ResultCode.OK || batchRecord.record == null; } - } diff --git a/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java b/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java index 72b6c86ad..61e699e20 100644 --- a/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java +++ b/src/test/java/org/springframework/data/aerospike/utility/AdditionalAerospikeTestOperations.java @@ -1,5 +1,6 @@ package org.springframework.data.aerospike.utility; +import com.aerospike.client.AerospikeException; import com.aerospike.client.Bin; import com.aerospike.client.IAerospikeClient; import com.aerospike.client.Key; @@ -16,7 +17,6 @@ import lombok.SneakyThrows; import lombok.Value; import org.awaitility.Awaitility; -import org.springframework.dao.RecoverableDataAccessException; import org.springframework.data.aerospike.core.WritePolicyBuilder; import org.springframework.data.aerospike.index.IndexesCacheRefresher; import org.springframework.data.aerospike.query.cache.IndexInfoParser; @@ -167,7 +167,7 @@ public void deleteAll(AerospikeRepository repository, Collection en if (ServerVersionUtils.isBatchWriteSupported(client)) { try { repository.deleteAll(entities); - } catch (RecoverableDataAccessException ignored) { + } catch (AerospikeException.BatchRecordArray ignored) { // KEY_NOT_FOUND ResultCode causes exception if there are no entities } } else {