Skip to content

Commit

Permalink
Add check that all values are of the correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Oct 10, 2019
1 parent 7d1fefb commit 935a954
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micronaut.core.annotation.AnnotationClassValue;
import io.micronaut.core.annotation.AnnotationUtil;
import io.micronaut.core.util.ArrayUtils;
import io.micronaut.core.util.StringUtils;
import io.micronaut.core.value.OptionalValues;
import io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder;
Expand Down Expand Up @@ -557,6 +558,13 @@ private class ArrayValueVisitor extends AbstractAnnotationValueVisitor8<Object,

Object[] getValues() {
if (arrayType != null) {
for (Object value : values) {
if (value != null) {
if (!arrayType.isInstance(value)) {
return ArrayUtils.EMPTY_OBJECT_ARRAY;
}
}
}
return values.toArray((Object[]) Array.newInstance(arrayType, values.size()));
} else {
return values.toArray(new Object[0]);
Expand Down

0 comments on commit 935a954

Please sign in to comment.