nosqlbench-1966 ArrayIndexOutOfBoundsException in ArgsComparator during resolveFunctions call

This commit is contained in:
Jonathan Shook 2024-06-24 11:56:39 -05:00
parent 883cde6fae
commit 014c82dc51
2 changed files with 11 additions and 4 deletions

View File

@ -89,7 +89,7 @@ public class NBSession extends NBHeartbeatComponent implements Function<List<Cmd
try (ResultContext results = new ResultContext(collector).ok()) {
for (Cmd cmd : assembledCommands) {
String explanation = " in context " + cmd.getTargetContext() + ", command '" + cmd.toString() + "'";
String explanation = "in container '" + cmd.getTargetContext() + "', command '" + cmd.toString() + "'";
try (NBInvokableCommand command = NBCommandAssembly.resolve(cmd,this::getContext)) {
NBCommandParams params = NBCommandAssembly.paramsFor(cmd);
NBBufferedContainer container = getContext(cmd.getTargetContext());

View File

@ -83,8 +83,14 @@ public class ArgsComparator implements Comparator<Constructor<?>> {
int paramLen = ctor.getParameterCount();
int argsLen = arguments.length;
if (paramLen!=argsLen && !ctor.isVarArgs()) {
return MATCHRANK.INCOMPATIBLE;
if (ctor.isVarArgs()) {
if (argsLen<paramLen-1) {
return MATCHRANK.INCOMPATIBLE;
}
} else {
if (paramLen!=argsLen) {
return MATCHRANK.INCOMPATIBLE;
}
}
int len = arguments.length; // only consider varargs if some provided
@ -94,7 +100,8 @@ public class ArgsComparator implements Comparator<Constructor<?>> {
Class<?>[] atypes = Arrays.stream(arguments).map(Object::getClass).toArray(i -> new Class<?>[i]);
for (int position = 0; position < len; position++) {
Class<?> ptype = ptypes[position];
Class<?> ptype = (position<ptypes.length) ? ptypes[position] : ptypes[ptypes.length-1];
Class<?> atype = (position<atypes.length) ? atypes[position] : atypes[atypes.length-1];
Class<?> across = WRAPPER_TYPE_MAP.get(atype);
Class<?> pcross = WRAPPER_TYPE_MAP.get(ptype);