Skip to content

Commit

Permalink
Fixes mockito#583 rework after PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-szewc committed Aug 28, 2016
1 parent 672b254 commit e112fb7
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,17 @@ private void captureVarargsPart(Invocation invocation) {
for (ArgumentMatcher m : uniqueMatcherSet(indexOfVararg)) {
if (m instanceof CapturesArguments) {
Object rawArgument = invocation.getRawArguments()[indexOfVararg];
for (int i = 0; i < getLength(rawArgument); i++) {
((CapturesArguments) m).captureFrom(getArgument(rawArgument, i));
if (rawArgument != null) {
for (int i = 0; i < Array.getLength(rawArgument); i++) {
((CapturesArguments) m).captureFrom(Array.get(rawArgument, i));
}
} else {
((CapturesArguments) m).captureFrom(null);
}
}
}
}

private int getLength(Object rawArgument) {
return rawArgument == null ? 1 : Array.getLength(rawArgument);
}

private Object getArgument(Object rawArgument, int i) {
return rawArgument == null ? null : Array.get(rawArgument, i);
}

private int regularArgumentsSize(Invocation invocation) {
return invocation.getMethod().isVarArgs() ?
invocation.getRawArguments().length - 1 // ignores vararg holder array
Expand Down

0 comments on commit e112fb7

Please sign in to comment.