From 22b9246da91d95225faf99f91904666af6af7409 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Mon, 6 Nov 2023 16:34:35 -0800 Subject: [PATCH] CLIENT-2667 Java proxy client: Create/Throw invalid namespace exception at the end of applicable batch reads on invalid namespace errors to be consistent with the java native client. --- .../aerospike/client/proxy/BatchProxy.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/proxy/src/com/aerospike/client/proxy/BatchProxy.java b/proxy/src/com/aerospike/client/proxy/BatchProxy.java index 4ae5a02f5..cef64b9da 100644 --- a/proxy/src/com/aerospike/client/proxy/BatchProxy.java +++ b/proxy/src/com/aerospike/client/proxy/BatchProxy.java @@ -202,6 +202,7 @@ public static final class GetArrayCommand extends BaseCommand { private final String[] binNames; private final Operation[] ops; private final int readAttr; + private Exception exc; public GetArrayCommand( GrpcCallExecutor executor, @@ -234,11 +235,19 @@ void parse(Parser parser, int resultCode) { if (resultCode == ResultCode.OK) { records[parser.batchIndex] = parseRecord(parser); } + else if (resultCode == ResultCode.INVALID_NAMESPACE) { + exc = new AerospikeException.InvalidNamespace(keys[parser.batchIndex].namespace, 1); + } } @Override void onSuccess() { - listener.onSuccess(keys, records); + if (exc == null) { + listener.onSuccess(keys, records); + } + else { + listener.onFailure(new AerospikeException.BatchRecords(records, exc)); + } } @Override @@ -311,6 +320,7 @@ public static final class ExistsArrayCommand extends BaseCommand { private final ExistsArrayListener listener; private final Key[] keys; private final boolean[] existsArray; + private Exception exc; public ExistsArrayCommand( GrpcCallExecutor executor, @@ -336,12 +346,23 @@ void parse(Parser parser, int resultCode) { if (parser.opCount > 0) { throw new AerospikeException.Parse("Received bins that were not requested!"); } - existsArray[parser.batchIndex] = resultCode == 0; + + if (resultCode == 0) { + existsArray[parser.batchIndex] = true; + } + else if (resultCode == ResultCode.INVALID_NAMESPACE) { + exc = new AerospikeException.InvalidNamespace(keys[parser.batchIndex].namespace, 1); + } } @Override void onSuccess() { - listener.onSuccess(keys, existsArray); + if (exc == null) { + listener.onSuccess(keys, existsArray); + } + else { + listener.onFailure(new AerospikeException.BatchExists(existsArray, exc)); + } } @Override