Skip to content

Commit

Permalink
CLIENT-2667 Java proxy client: Create/Throw invalid namespace excepti…
Browse files Browse the repository at this point in the history
…on at the end of applicable batch reads on invalid namespace errors to be consistent with the java native client.
  • Loading branch information
BrianNichols committed Nov 7, 2023
1 parent c0f6ebd commit 22b9246
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions proxy/src/com/aerospike/client/proxy/BatchProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 22b9246

Please sign in to comment.